     (.put out-queue (annotate-image image event))))
   
 (defn store-z-correction [z event]
-  (alter z-corrections assoc (get-in event [:position :label]) z))
+  (alter state assoc-in [:z-corrections (get-in event [:position :label])] z))
  
 (defn compute-z-position [event]
   (if-let [z-drive (:z-drive event)]
     (-> event
       (assoc :z
 				(+ (or (get-in event [:channel :z-offset]) 0)
-				   (or (get @z-corrections z-drive)
+				   (or (get (@state :z-corrections) z-drive)
 				     (:slice event)
-				     default-z-position)))
+				     (@state :last-z-position))))
       (assoc-in [:postion :axes z-drive] nil))
     event))
    

  (concat
    (when-let [z-drive (:z-drive event)]
      (when-let [z (:z event)]
        (list [z-drive #(set-stage-position z-drive z)])))
    (for [[axis pos] (get-in event [:position :axes])]
      [axis #(apply set-stage-position axis pos)])
    (for [prop (get-in event [:channel :properties])]

(defn annotate-image [img event]
  (TaggedImage. img
    (JSONObject. (merge
      {"ElapsedTime-ms" (- (clock-ms) (@state :start-time))
       "Time" (get-current-time-str)
       "Width"  (. mmc getImageWidth)
       "Height" (. mmc getImageHeight)
       "PixelType" (get-pixel-type)
       "Binning" (. mmc getProperty (. mmc getCameraDevice) "Binning")
       "UUID" (UUID/randomUUID)
      }
