   [formula-name title notes params]
   (let [j (job formula-name title notes params)]
     (insert database/jobs (values j))
-    (dosync
-     (ref-set current-job j)
-     j)))
+    (reset! current-job j)
+    j))
 
 (defn stop-job
   "Marks the currently running job as stopped"


(def emitter (lc/channel* :permanent? true :grounded? true))

(def current-job (ref nil))

(defn job
  "Creates a new job map"

  (ctrl/stop-job)
  (when-let [job (dosync
                  (when-let [job @current-job]
                    (reset! current-job nil)
                    job))]
    (update database/jobs
            (set-fields {:ended-at (System/currentTimeMillis)})
