          "  ns = " ns ";\n"
          "  for (key in ns) {\n"
          "    if (!ns.hasOwnProperty(key)) { continue; }\n"
-         "    value = ns[key];"
-         ;; defmulti declares a defonce to hold its state. As noted below,
-         ;; we purposely set defonce'd members to null so they aren't redefined.
-         ;; Not redefining a multi causes defmethod failures on reload.
-         ;;
-         ;; Luckily, there is a handy `cljs.core/remove-all-methods` function to clear
-         ;; a multimethod's state. The trick then is to figure out which members
-         ;; are multimethods. The check below seems reliable.
-         "    if (typeof value !== 'undefined' && \n
-                         value !== null && \n
-                    typeof value.constructor !== 'undefined' && \n
-                           value.constructor !== null && \n
-                      value.constructor.cljs$lang$ctorStr === 'cljs.core/MultiFn') {\n"
-         "      cljs.core.remove_all_methods.call(null, value);\n"
+         "    if (!on_state_path(key)) {\n"
          "      delete ns[key];\n"
-         "    } else {\n"
-         ;; setting to null is critical to allow defonce to work as expected.
-         ;; defonce checks typeof var == "undefined"
-         ;; we need to allow certain vars to _not_ be redefined in order to
-         ;; maintain only one repl connection.
-         ;;
-         ;; I'm not certain, but it seemed like multiple connections usually
-         ;; resulted in stackoverflows in goog.require.
-         "      ns[key] = null;\n"
          "    }\n"
          "  }\n
          }\n"
          loaded-libs " = cljs.core.disj.call(null, " loaded-libs ", ns_string);\n"
          "})();")))
 
-(defn unload-nss-script [nss]
+(defn unload-nss-script [state-sym nss]
   (str/join "\n"
-            (map compile-unload-ns
+            (map (partial compile-unload-ns state-sym)
                  nss)))
 
 (defn load-nss-sync [nss]

    (eval-script repl-env
                 (str "(function() {\n"
                      (call-sym-script before)
                      (set-ti-state-from-sym-script state)
                      (unload-nss-script unload-nss)
                      "var d = " (load-nss-html-async load-nss) ";\n"
                      "d.addCallback(function(ret) {\n"
                      (set-sym-from-ti-state-script state)
                      (call-sym-script after)
                      "  });\n"
                      "})();"))))

                             :analyzer-env analyzer-env
                             :repl-opts repl-opts}))))

     'print-disabled
     (wrap (fn [& _]
             (prn :disabled-unload @disable-unload)
