 (deftype Invalidate [path]
   RouteResult
   (update-context [_ context _]
-    ;; TODO: remove this fnil -- context should have this to start!
-    (update context :invalidate (fnil conj []) path)))
+    (update context :invalidate conj path)))
 
 (defn invalidate [path]
   (Invalidate. path))

                      results (for [[match values] results
                                    value values]
                                [match value])
                      [context paths] (merge-results context results)]
                  (cons (dissoc context :method)
                        (execute* context paths)))
                nil)))]
    (execute* {:method method
               :graph {}
               :paths []}
              pathsets)))

(defn gets [{:keys [route-tree]} pathsets ctx]
  (letfn [(runner [{:keys [handler]} path _]
            ((:get handler) path ctx))]
    (execute route-tree :get runner pathsets)))

(defn get
  ([router pathsets]
   (get router pathsets {}))
  ([router pathsets ctx]
   (last (gets router pathsets ctx))))

(defn sets [{:keys [route-tree]} pathmaps ctx]
  (let [{:keys [graph paths]} (graph/set {} pathmaps)
        ;; TODO: not sure if this is necessary
        paths (core/expand-pathsets paths)]
    (letfn [(runner [{:keys [method handler request virtual]} pathset execution-context]
              (case method
                :get ((:get handler) pathset ctx)
                :set (let [cache (:graph execution-context)
                           optimized-with-path (for [path paths
                                                     :let [optimized (first (core/optimize cache [path]))]

                                             {}
                                             optimized-with-path)
                           pathmap (:graph (graph/get set-graph [request]))]
                  ((:set handler) pathmap env))))]
      (let [pathsets (core/collapse paths)]
        (execute route-tree
                 (init-context :set pathsets env)
                 runner)))))

(defn set
  ([router pathmaps]
   (set router pathmaps {}))
  ([router pathmaps env]
   (last (sets router pathmaps env))))

(defn calls [{:keys [route-tree]} call-path args queries env]
  (letfn [(runner [{:keys [method handler request]} matched-path _]
            (case method
              :get ((:get handler) matched-path env)
              :call (let [results ((:call handler) matched-path args env)
                          ;; expand pathmaps so we can search for refs
                          results (into [] (mapcat (fn [result]
                                                     (if (core/pathmap? result)
