   [mkeys tenant period rollup time ttl fn-get fn-agg fn-store]
   (let [mkey (construct-mkey tenant period rollup time)]
     (swap! mkeys
-           (fn [at-mkeys]
-             (if (contains? at-mkeys mkey)
-               at-mkeys
-               (let [pkeys (atom #{})
-                     flusher (create-flusher mkeys mkey pkeys tenant period
-                                             rollup time ttl fn-get fn-agg
-                                             fn-store)
-                     delayer (run-delayer! rollup flusher)]
-                 (swap! pkeys
-                        (fn [pkeys]
-                          (with-meta pkeys {:flusher flusher :delayer delayer
-                                            :data (atom {})})))
-                 (assoc at-mkeys mkey pkeys)))))
+           #(if (contains? % mkey)
+              %
+              (let [pkeys (atom #{})
+                    flusher (create-flusher mkeys mkey pkeys tenant period
+                                            rollup time ttl fn-get fn-agg
+                                            fn-store)
+                    delayer (run-delayer! rollup flusher)]
+                (swap! pkeys
+                       (fn [pkeys]
+                         (with-meta pkeys {:flusher flusher :delayer delayer
+                                           :data (atom {})})))
+                (assoc % mkey pkeys))))
     (get @mkeys mkey)))
 
 (defn set-keys!
   [mkeys tenant period rollup time path ttl fn-get fn-agg fn-store]
   (let [pkeys (set-pkeys! mkeys tenant period rollup time ttl fn-get
                           fn-agg fn-store)]
-    (swap! pkeys
-           (fn [pkeys]
-             (if (contains? pkeys path)
-               pkeys
-               (conj pkeys path))))
+    (swap! pkeys #(if (contains? % path) % (conj % path)))
     pkeys))
 
 (defn simple-cache

    (doseq [path @pkeys]
      (fn-store tenant period rollup time path
                (fn-agg (fn-get (construct-key mkey path) @pkeys)) ttl))
    (swap! mkeys (fn [mkeys] (dissoc mkeys mkey)))))

(defn run-delayer!
  [rollup flusher]

              pkeys (set-keys! mkeys tenant period rollup time path ttl fn-get
                               fn-agg fn-store)
              adata (get-data @pkeys)]
          (swap! adata #(assoc % ckey (conj (get % ckey) data)))))
      (flush! [this]
        (doseq [[mkey pkeys] @mkeys]
          (let [delayer (get (meta @pkeys) :delayer nil)]
