   "Creates a new in-memory block store."
   [& {:as opts}]
   (map->MemoryBlockStore
-    (assoc opts :memory (atom (sorted-map) :validator map?))))
+    (assoc opts :memory (ref (sorted-map) :validator map?))))
 
 
 (defmethod store/initialize "mem"

  (merge (block/meta-stats block)
         {:id (:id block)
          :size (:size block)}))


;; Block records in a memory store are held in a map in an atom.

  (-put!
    [this block]
    (when-let [id (:id block)]
      (dosync
        (if-let [extant (get @memory id)]
          extant
          (let [block (prep-block block)]
            (alter memory assoc id block)
            block)))))


  (-delete!
    [this id]
    (dosync
      (let [existed? (contains? @memory id)]
        (alter memory dissoc id)
        existed?)))


  store/BatchingStore

  (-get-batch
    [this ids]
    (keep @memory ids))


  (-put-batch!
    [this blocks]
    (dosync
      (reduce
        (fn [acc block]
          (if-let [extant (get @memory (:id block))]
            (conj acc extant)
            (let [block (prep-block block)]
              (alter memory assoc (:id block) block)
              (conj acc block))))
        [] blocks)))


  (-delete-batch!
    [this ids]
    (dosync
      (reduce
        (fn [acc id]
          (if (contains? @memory id)
            (do (alter memory dissoc id)
                (conj acc id))
            acc))
        [] ids)))


  store/ErasableStore

  (-erase!
    [this]
    (dosync
      (alter memory empty))
    this))



