                         (when (empty? watches)
                               (-remove-child signal this))))
 
-(defn make-base [parent]
-      (let [base (BaseSignal. parent #{})]
-           (-add-watch parent base
-                       (fn [_ old-val new-val]
-                           (if (not= old-val new-val)
-                             (-refresh-children base))))
-           base))
-
-(defn make-derived [path f]
+
+
+(defn- make-derived [path f]
       (let [derived (DerivedSignal. path f nil -1 #{} #{})]
            (-refresh derived)
            (activate-signal path derived)
            derived))
 
-(defn add-refresh-queue [signal depth]
+(defn- add-refresh-queue [signal depth]
       (if-let [depth-queue (refresh-queue depth)]
               (set! refresh-queue
                     (assoc refresh-queue depth (conj depth-queue signal)))
               (set! refresh-queue
                     (assoc refresh-queue depth #{signal}))))
 
-(defn remove-refresh-queue [signal depth]
+(defn- remove-refresh-queue [signal depth]
       (let [depth-queue (refresh-queue depth)]
            (if (= 1 (count depth-queue))
              (set! refresh-queue (dissoc refresh-queue depth))
              (set! refresh-queue
                    (assoc refresh-queue depth (disj depth-queue signal))))))
 
-(defn enqueue-refresh [signals]
+(defn- enqueue-refresh [signals]
       (doseq [signal signals]
              (add-refresh-queue signal (-get-depth signal))))
 
-(defn refresh []
+(defn- refresh []
       (while (seq refresh-queue)
              (doseq [depth-queue (vals refresh-queue)]
                     (doseq [signal depth-queue]
                            (remove-refresh-queue signal (-get-depth signal))
                            (-refresh signal)))))
 
-(defn run-with-deref-capture [signal]
+(defn- run-with-deref-capture [signal]
       (if capturing?
         (let [child signal-being-captured
               childs-captured captured-parents]

                   (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)

