   (+ @-running))
 
 (defn capture-derefed [f obj]
-  (set! (.-cljsCaptured obj) nil)
-  ;; (if-not (nil? (.-watching obj))
-  ;;   (set! (.-reaPos obj) 0))
-  (set! (.-reaPos obj) -1)
+  (set! (.-cljsCaptured obj) (.-watching obj))
+  (set! (.-reaPos obj) 0)
   (when (dev?)
     (set! (.-ratomGeneration obj)
           (set! generation (inc generation))))

    (f)))

(defn captured [obj]
  (when-not (and (== -1 (.-reaPos obj))
                 (nil? (.-cljsCaptured obj)))
    obj))

(defn- -captured [obj]
  (let [c (.-cljsCaptured obj)]
    (set! (.-cljsCaptured obj) nil)
    (if (nil? c)
      (when (== (inc (.-reaPos obj))
                (some-> (.-watching obj) alength))
        (.-watching obj))
      c)))

(defn- add-item [a x]
  (when (== -1 (.indexOf a x))

  (when-some [obj *ratom-context*]
    (let [c (.-cljsCaptured obj)]
      (if (nil? c)
        (do (set! (.-reaPos obj) -1)
            (set! (.-cljsCaptured obj) (array derefable)))
        ;; Try to avoid allocating new array
        (let [p (.-reaPos obj)]
          (if (and (not (== p -1))
                   (identical? derefable (aget c p)))
            (set! (.-reaPos obj) (inc p))
            (if (== p -1)
              (add-item c derefable)
              (let [c1 (set! (.-cljsCaptured obj) (.slice c 0 p))]
                (add-item c1 derefable)
                (set! (.-reaPos obj) -1))))))))
  nil)

(defn- ^number arr-len [x]
