          (sort-by :order))))
 
 (defn- bring [states fun order]
-  (->> states
-       (sort-by (comp :order meta) order)
-       (map #(fun % (meta %)))
-       doall))
+  (let [done (atom #{})]
+    (->> states
+         (sort-by (comp :order meta) order)
+         (map #(fun % (meta %) done))
+         doall)
+    @done))
 
 (defn merge-lifecycles 
   "merges with overriding _certain_ non existing keys. 


(defn start [& states]
  (let [states (or (seq states) (all-without-subs))]
    (bring states up <)
    :started))

(defn stop [& states]
  (let [states (or states (find-all-states))]
    (doall (map unsub states))     ;; unmark substitutions marked by "start-with"
    (bring states down >)
    (doall (map rollback! states)) ;; restore to origin from "start-with"
    :stopped))

(defn stop-except [& states]
  (let [all (set (find-all-states))
        states (remove (set states) all)]
    (doall (map unsub states))     ;; unmark substitutions marked by "start-with"
    (bring states down >)
    (doall (map rollback! states)) ;; restore to origin from "start-with"
    :stopped))

(defn start-with-args [xs & states]
  (reset! -args xs)


(defn suspend [& states]
  (let [states (or (seq states) (all-without-subs))]
    {:suspended (bring states sigstop <)}))

(defn resume [& states]
  (let [states (or (seq states) (all-without-subs))]
    {:resumed (bring states sigcont <)}))
