   (->
    (update state :election-timeout - dt)
    (apply-commit-index)
-   (utils/if-not-leader? check-election-timeout)
+   (utils/if-not-leader? f/check-election-timeout)
    (process-rx-packets)
-   (utils/if-leader? check-backlog dt)
+   (utils/if-leader? l/check-backlog dt)
    (utils/if-leader? cs/check-clients)))
 
 (defn set-peers [state peers]

            (and (= :candidate (:type state))
                 (= :append-entries (:type params))
                 (<= (:current-term state) (:term body))))
      (become-follower (assoc state :current-term (:term body))
                       (:leader-id body))
      (if (:leader-id body)
        (assoc state :leader-id (:leader-id body))
        state))))


(defn handle-append-entries-response [state p]
  (if (pos? (get-in p [:body :count])) ; heart beat response
    (l/check-and-update-append-entries state p)
    (update state :clients cs/inc-heartbeats (:src p))))

(defn client-read
  [state pkt]
  (let [[s response] (cs/add-read state pkt)]
    (if (= :broadcast-heart-beat response)
      (l/broadcast-heartbeat s)
      (utils/transmit s response))))

(defn- handle-get [state p]
  (client-read state p))

(defn- handle-packet
  [state]
  (let [p (first (:rx-queue state))
        s (check-term state p)]
    (condp = (:type p)
      :get (handle handle-get s p)
      :set (handle handle-set s p)
      :cas (handle handle-cas s p)
      :request-vote (f/handle-request-vote s p)
      :request-vote-reply (c/handle-request-vote-response s p)
      :append-entries (f/handle-append-entries s p)
      :append-entries-response (handle-append-entries-response s p))))

(defn- process-rx-packets [state]
