    
 (def attached-runnables (atom (vec nil)))
 
-(def pending-devices (atom nil))
+(def pending-devices (atom #{}))
 
 (defn add-to-pending [dev]
   (swap! pending-devices conj dev))

;; hardware control

(defn wait-for-device [dev]
  (when (and dev (pos? (.length dev)))
    (core waitForDevice dev)))

(defn wait-for-pending-devices []
  (dorun (map wait-for-device @pending-devices))
  (reset! pending-devices nil))

(defn get-z-stage-position [stage]
  (if-not (empty? stage) (core getPosition stage) 0))


(defn init-burst [length trigger-sequence]
  (when trigger-sequence
    (log trigger-sequence)
    (arm-property-sequences trigger-sequence))
  (core setAutoShutter (@state :init-auto-shutter))
  (swap! state assoc :burst-init-time (elapsed-time @state))
