         runs (get plan :runs [0])
         cache (read-hyperspectral-cache hs-cache-filename)
         samples (get plan :samples [2500000])
-        embed (get plan :embed true)]
+        embed (get plan :embed true)
+        save-every (get plan :save-every)]
     (doseq [image-count samples
             run runs]
       (if verbose
         (println (format "Simulating %d retinas with %d samples from cache %s (run = %d)..."
                          (count my-retinas) image-count hs-cache-filename run)))
-      (let [corr-mtcs (if verbose
-                        (simulate-retinas
-                         my-retinas cache
-                         :image-count image-count
-                         :init-reduce (cons [0 nil] (repeat (dec (count my-retinas)) nil))
-                         :analysis (cons (fn [[iter dat] sig]
-                                           (if (= 0 (mod iter 1000))
-                                             (println "Iteration " iter "..."))
-                                           [(inc iter) (correlation-analysis dat sig)])
-                                         (repeat (dec (count my-retinas)) correlation-analysis))
-                         :finish (cons (fn [[iter dat]]
-                                         (println "Simulation complete after " iter " iterations.")
-                                         (correlation-analysis dat))
-                                       (repeat (dec (count my-retinas)) correlation-analysis)))
-                        (simulate-retinas my-retinas (val cache) :image-count image-count))
+      (let [[inits analfns finfns] (make-analysis save-every
+                                                  (when verbose print-every)
+                                                  my-retinas
+                                                  run
+                                                  embed)
+            corr-mtcs (simulate-retinas my-retinas cache
+                                        :image-count image-count
+                                        :init-reduce inits
+                                        :analysis analfns
+                                        :finish finfns)
             flnms (map #(str output-dir "/" (simulation-filename % image-count run)) my-retinas)]
         (doall
          (map #(write-simulation %1 %2 %3 :embed embed)

                 :else ""))
         "].bin")))

;; a function for simulating some of the retinas; given the total number of jobs and
;; a a job id, this will simulate and write out the results for the appropriate chunk
;; of simulations from the given set. The plan should be :basic or :standard.
(defn simulate-some-retinas [plan-id hs-cache-filename output-dir total-nodes node-id
                             &{:keys [verbose]}]
  (let [plan (get simulation-plans plan-id)
        plan-retinas (retinas-from-plan plan)
        my-retinas (if (coll? node-id)

                 :sizes [20 15 10 5]
                 :S-cone-flags [:human]
                 :samples [2500000]
                 :runs [0]
                 :save-every 100000}
      :savetest {:surrounds [[0.25 3.0]]
                 :L-to-Ms [[4 1]]
                 :M-lambda-maxs [535 540]
                 :L-lambda-maxs [558.9]
                 :S-lambda-maxs [420.7]
                 :sizes [10 5]
                 :S-cone-flags [:human]
                 :samples [100]
                 :save-every 20
                 :runs [3]}
      :test     {:surrounds [[0.25 3.0] nil]
                 :L-to-Ms [[16 1] [8 1] [4 1]]
                 :M-lambda-maxs [535 540]
