               0))
          z-ref))))
 
+(defn z-stage-needs-adjustment [stage-name]
+  (or (not (@state :init-continuous-focus))
+      ;(not (core isContinuousFocusEnabled))
+      (core isContinuousFocusDrive stage-name)))
+
 (defn update-z-positions [msp-index]
   (when-let [msp (get-msp msp-index)]
     (dotimes [i (.size msp)]
       (let [stage-pos (.get msp i)
             stage-name (.stageName stage-pos)]
         (when (= 1 (.numAxes stage-pos))
-          (when (or (not (core isContinuousFocusEnabled))
-                    (core isContinuousFocusDrive stage-name))
+          (when (z-stage-needs-adjustment stage-name)
             (set-msp-z-position msp-index stage-name (get-z-stage-position stage-name))))))))
 
 (defn recall-z-reference [current-position]
   (let [z-drive (@state :default-z-drive)]
-    (when (or (not (core isContinuousFocusEnabled))
-              (core isContinuousFocusDrive z-drive))
-      (set-z-stage-position z-drive
+    (when (z-stage-needs-adjustment z-drive)
+      (set-stage-position z-drive
         (or (get-msp-z-position current-position z-drive)
             (@state :reference-z))))))
 
 (defn store-z-reference [current-position]
   (let [z-drive (@state :default-z-drive)]
-    (when (and (or (not (core isContinuousFocusEnabled))
-                   (core isContinuousFocusDrive z-drive)))
+    (when (z-stage-needs-adjustment z-drive)
       (let [z (get-z-stage-position z-drive)]
         (state-assoc! :reference-z z)))))
 

            #(set-property [d p v]))
          #(when-lets [exposure (:exposure event)
                       camera (core getCameraDevice)]
             (device-best-effort (set-exposure camera exposure)))
          #(when check-z-ref
             (recall-z-reference current-position))
          #(when-let [wait-time-ms (:wait-time-ms event)]

(defn acq-sleep [interval-ms]
  (log "acq-sleep")
  (when (and (@state :init-continuous-focus)
             (not (core isContinuousFocusEnabled)))
    (core enableContinuousFocus true))
  (let [target-time (+ (@state :last-wake-time) interval-ms)
        delta (- target-time (jvm-time-ms))]
    (when (pos? delta)
