 (def messaging 
   (component/start (aeron/aeron {:opts peer-config})))
 
-(defn bump-forward-immediates [entries peers peer-id]
+(defn bump-forward-immediates 
+  "If peer hasn't finished joining yet, bump all their 
+  log entries to the head of their queue. Order is otherwise stable."
+  [entries peers peer-id]
   (if ((set peers) peer-id)
     entries
     (vec (concat (filter :immediate? entries)
                  (remove :immediate? entries)))))
 
+(defn active-peers [replica entry]
+  (cond-> (set (concat (:peers replica)
+                       ; might not need these with the below entries
+                       (vals (or (:prepared replica) {})) 
+                       (vals (or (:accepted replica) {}))))
+    (:id (:args entry)) (conj (:id (:args entry)))
+    (:joiner (:args entry)) (conj (:joiner (:args entry)))))
+
 (defn apply-entry [replica entries entry]
   (let [new-replica (extensions/apply-log-entry entry replica)
         diff (extensions/replica-diff entry replica new-replica)
-        peers (cond-> (set (concat (:peers replica)
-                                   ; might not need these with the below entries
-                                   (vals (or (:prepared replica) {})) 
-                                   (vals (or (:accepted replica) {}))))
-                (:id (:args entry)) (conj (:id (:args entry)))
-                (:joiner (:args entry)) (conj (:joiner (:args entry))))
+        peers (active-peers replica entry)
         peer-reactions (keep (fn [peer-id] 
                                (if-let [reactions (extensions/reactions entry 
                                                                         replica 

  (checking
    "Checking joins"
    10000
    [{:keys [replica peer-choices]} 
     (apply-entries-gen 
       (gen/return
         {:replica {:job-scheduler (:onyx.peer/job-scheduler peer-config)
                    :messaging (:onyx.messaging/config peer-config)}
          :message-id 0
          :entries {:a [{:fn :prepare-join-cluster 
                         :immediate? true
                         :args {:peer-site (extensions/peer-site messaging)

                          peer-reactions)]
    (vector new-replica unapplied)))

(defn apply-peer-queue-entry 
  "Applies the next log message in the selected peer's queue.
  Effectively, the next peer that wrote its message to ZK"
  [{:keys [replica message-id entries peer-choices log]} next-peer] 
  (let [peer-queue (entries next-peer)
        next-entry (first peer-queue)
        new-peer-queue (vec (rest peer-queue))
