     (load-push-argmap argmap)
     (reset-globals)))
 
-(defn make-agents-and-rng
-  [{:keys [use-single-thread population-size random-seed
-           max-genome-size-in-initial-program atom-generators
-           save-initial-population]
+(defn agent-error-handler
+  "Given to individual agents for handling errors."
+  [agnt except]
+  ;(.printStackTrace except System/out)
+  ;(.printStackTrace except)
+  (repl/pst except 10000)
+  (System/exit 0))
+
+(defn make-pop-agents
+  "Makes the population of agents containing the initial random individuals in the population.
+   Argument is a push argmap"
+  [{:keys [use-single-thread population-size
+           max-genome-size-in-initial-program atom-generators]
     :as argmap}]
-  (let [agent-error-handler (fn [agnt except]
-                              ;(.printStackTrace except System/out)
-                              ;(.printStackTrace except)
-                              (repl/pst except 10000)
-                              (System/exit 0))
-        random-seeds (loop [seeds '()]
+  (let [population-agents (repeatedly population-size
+                                      #(make-individual
+                                         :genome (random-plush-genome max-genome-size-in-initial-program
+                                                                      atom-generators
+                                                                      argmap)
+                                         :genetic-operators :random))]
+    (mapv #(if use-single-thread
+             (atom %)
+             (agent % :error-handler agent-error-handler))
+          population-agents)))
+
+(defn make-child-agents
+  "Makes the population of agents containing the initial random individuals in the population.
+   Argument is a push argmap."
+  [{:keys [use-single-thread population-size]}]
+  (vec (repeatedly population-size
+                   #((if use-single-thread atom agent)
+                      (make-individual)
+                      :error-handler agent-error-handler))))
+
+(defn make-rng
+  "Creates the random number generators used by the agents in the population.
+   Argument is a push argmap"
+  [{:keys [population-size]}]
+  (let [random-seeds (loop [seeds '()]
                        (let [num-remaining (- population-size (count seeds))]
                          (if (pos? num-remaining)
                            (let [new-seeds (repeatedly num-remaining #(random/lrand-bytes (:mersennetwister random/*seed-length*)))]                             

                                                            (not (some #(random/=byte-array % candidate)
                                                                       seeds))) new-seeds)))); only add seeds that we do not already have
                           seeds)))]
    {:pop-agents (let [pa (doall (for [_ (range population-size)]
                                   (make-individual
                                     :genome (random-plush-genome max-genome-size-in-initial-program
                                                                  atom-generators
                                                                  argmap)
                                     :genetic-operators :random)))
                       f (str "data/" (System/currentTimeMillis) ".ser")]
                   (when save-initial-population
                     (io/make-parents f)
                     (spit f (printable (map individual-string pa))))
                   (vec (map #(if use-single-thread
                                (atom %)
                                (agent % :error-handler agent-error-handler))
                             pa)))
     :child-agents (vec (doall (for [_ (range population-size)]
                                 ((if use-single-thread atom agent)
                                      (make-individual)
                                      :error-handler agent-error-handler))))
     :random-seeds random-seeds
     :rand-gens (vec (doall (for [k (range population-size)]                      
                              (random/make-mersennetwister-rng (nth random-seeds k)))))
     }))

      (timer @push-argmap :initialization)
      (println "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;")
      (println "\nGenerating initial population...")
      (let [pop-agents (make-pop-agents @push-argmap)
            child-agents (make-child-agents @push-argmap)
            {:keys [rand-gens random-seeds]} (make-rng @push-argmap)]
        ;(print "Random seeds: ")
        ;(doseq [seed random-seeds] (print " " seed))
        ;(println)
