     (when-not (empty? z-drive)
       (when (z-stage-needs-adjustment z-drive)
         (let [z (get-z-stage-position z-drive)]
-          (state-assoc! :reference-z z))))))
+          (swap! state assoc :reference-z z))))))
 
 ;; startup and shutdown
 


(defn interruptible-sleep [time-ms]
  (let [sleepy (CountDownLatch. 1)]
    (state-assoc! :sleepy sleepy :next-wake-time (+ (jvm-time-ms) time-ms))
    (.await sleepy time-ms TimeUnit/MILLISECONDS)))

(defn acq-sleep [interval-ms]

;; globals

(def ^:dynamic state (atom {:stop false}))

(def attached-runnables (atom (vec nil)))

