                  (set! captured-parents nil)
                  captured))))
 
-(defn unbind-dependency [parent child]
+(defn- unbind-dependency [parent child]
       (-remove-parent child parent)
       (-remove-child parent child))
 
-(defn bind-dependency [parent child]
+(defn- bind-dependency [parent child]
       (-add-parent child parent)
       (-add-child parent child))
 
-(defn notify-deref-watcher [signal]
+(defn- notify-deref-watcher [signal]
       (when capturing?
             (set! captured-parents (conj captured-parents signal))))
 
 ; subscriptions
 
-(def active-signals {})
-(def default-signal-fn nil)
-(def registered-derived-signal-fns {})
-
-(defn register-derived-signal-fn [path f]
-      (set! registered-derived-signal-fns
-            (assoc-in registered-derived-signal-fns path f)))
-
-(defn register-default-signal-fn [f]
-      (set! default-signal-fn f))
-
-(defn get-in-atom-signal-fn [atom]
-      (let [base (make-base atom)]
-           (fn [path]
-               (get-in @base path))))
+(defonce active-signals {})
+(defonce default-signal-fn nil)
+(defonce registered-derived-signal-fns {})
 
 (defn- path->derived-signal-fn [path]
        (loop [node registered-derived-signal-fns path path]

                   (ifn? node)
                   (node path))))

(defn path->signal-fn [path]
      (if-let [f (path->derived-signal-fn path)]
              f
              #(default-signal-fn path)))

(defn path->signal [path]
      (if-let [signal (active-signals path)]
              signal
              (make-derived path (path->signal-fn path))))

(defn activate-signal [path signal]
      (set! active-signals (assoc active-signals path signal)))

(defn deactivate-signal [path]
      (set! active-signals (dissoc active-signals path)))

(defn reference [path]
      (SignalReference. path))

(defn subscribe [path]
      (let [sub (ManualSubscription. (path->signal path))]

  (:require [clojure.set :as set]
            [reagent.ratom :as reagent]))

(defonce capturing? false)
(defonce captured-parents nil)
(defonce signal-being-captured nil)
(defonce refresh-queue (sorted-map))

(declare path->signal)

