   [sec]
   (* sec 1000))
 
-(defn set-tkeys!
-  [mkeys tenant period rollup]
-  (let [mkey (construct-mkey tenant period rollup)]
-    (swap! mkeys
-           (fn [mkeys]
-             (if (contains? mkeys mkey)
-               mkeys
-               (assoc mkeys mkey (atom {})))))
-    (get @mkeys mkey)))
-
 (defn create-flusher
- [mkeys tkeys pkeys tenant period rollup time ttl fn-get fn-agg fn-store]
+ [mkeys mkey pkeys tenant period rollup time ttl fn-get fn-agg fn-store]
  (fn []
    (doseq [path @pkeys]
      (fn-store tenant period rollup time path (fn-agg (fn-get path)) ttl)
-     (swap! tkeys (fn [tkeys] (dissoc tkeys time)))
-     (let [mkey (construct-mkey tenant period rollup)]
-       (swap! mkeys (fn [mkeys]
-                      (when (empty? tkeys)
-                        (dissoc mkeys mkey)
-                        mkeys)))))))
+     (swap! mkeys (fn [mkeys] (dissoc mkeys mkey))))))
 
 (defn run-delayer!
   [rollup flusher]

  [data]
  (/ (reduce + data) (count data)))

(defn construct-key
  [tenant period rollup time path]
  (str/join "-" [tenant period rollup time path]))

(defn construct-mkey
  [tenant period rollup]
  (str/join "-" [tenant period rollup]))

(defn calc-delay
  [rollup add]

    delayer))

(defn set-pkeys!
  [mkeys tenant period rollup time ttl fn-get fn-agg fn-store]
  (let [mkey (construct-mkey tenant period rollup time)]
    (swap! mkeys
           (fn [mkeys]
             (if (contains? mkeys mkey)
               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})))
                 (assoc mkeys 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]
