     (log (@state :last-positions) "," stage-dev)
     (when (not= z (get-in @state [:last-positions stage-dev]))
       (device-best-effort stage-dev (set-z-stage-position stage-dev z))
-      (swap! state assoc-in [:last-positions stage-dev] z)
+      (store-last-z-position z)
       (add-to-pending stage-dev)))
   ([stage-dev x y]
     (log (@state :last-positions) "," stage-dev)

(defn add-to-pending [dev]
  (swap! pending-devices conj dev))

;; time

(defn clock-ms []

      (interruptible-sleep delta))
    (await-resume)
    (let [now (clock-ms)
          wake-time (if (> now (+ target-time 10)) now target-time)
          stage-dev (core getFocusDevice)
          z (get-z-stage-position stage-dev)]
      (state-assoc! :last-wake-time wake-time
                    :reference-z-position z)
      (store-last-z-position z))))

;; image metadata

