   (let [s @storage
         sq (get (:keys s) key)
         change (get (:changes s) sq)]
-    (if (and change (not (:deletion change)))
+    (if (and change (not (:deleted change)))
       {:opaque opaque :status :ok
        :key key :sq sq :cas (:cas change) :val (:val change)}
       {:opaque opaque :status :not-found

  (let [cas (gen-cas)
        storage2 (swap! storage
                        #(-> %
                             (dissoc-in [:changes (get-in % [:keys key :sq])])
                             (assoc-in [:keys key] (:next-sq %))
                             (assoc-in [:changes (:next-sq %)]
                                       {:key key :sq (:next-sq %) :cas cas :val val})

(defn storage-del [storage opaque key]
  (let [storage2 (swap! storage
                        #(-> %
                             (assoc :max-deleted-sq (max (get-in % [:keys key])
                                                         (:max-deleted-sq %)))
                             (dissoc-in [:changes (get-in % [:keys key])])
                             (dissoc-in [:keys key])
                             (assoc-in [:changes (:next-sq %)]
                                       {:key key :sq (:next-sq %) :deleted true})
                             (update-in [:next-sq] inc)))]
    {:opaque opaque :status :ok
     :key key :sq (dec (:next-sq storage2))}))

(defn make-storage-cmd-handlers [storage]
  {"get" [["key"]
