                  tuples)]
     ;; loop the end to the front to finish it
     (-> counted
-        (update-in [(.hashCode last-edge) (.hashCode first-edge)] incr-or-one)
-        (update-in [(.hashCode last-edge) :total] incr-or-one))))
+        (update-in [(.hashCode last-node) (.hashCode first-node)] incr-or-one)
+        (update-in [(.hashCode last-node) :total] incr-or-one))))
 
 (defn counted-probabilities
   [counted]
   (map
-   (fn [[request edges]]
+   (fn [[request nodes]]
      [request
-      (reduce (fn [m [ereq ecount]]
-                (if (= ereq :total)
+      (reduce (fn [m [nreq ncount]]
+                (if (= nreq :total)
                   m
-                  (assoc m ereq (float (/ ecount (:total edges))))))
+                  (assoc m nreq (float (/ ncount (:total nodes))))))
               {}
-              edges)])
+              nodes)])
    counted))
+
+(defn weighted-requests
+  [{total :total :as requests}]
+  (reduce
+   (fn [m [k v]]
+     (if (= k :total)
+       m
+       (let [[_ cnt] v]
+         (assoc m k (/ cnt total)))))
+   {}
+   requests))
 
 (defn compile-preprocessed
   "Compiles a preprocessed corpus into a format suitable for the (chain) method"
   [{:keys [requests counted]}]
   (let [probabilities (counted-probabilities counted)]
     {:requests requests
-     :request-keys (vec (filter #(not= :total %) (keys requests)))
+     :weighted-requests (counts->treemap (weighted-requests requests))
      :transitions (compile-transitions probabilities)}))
 
 (defn parse

     :counted counted}))

(defn corpus-chain
  [corpus]
  (-> corpus
      preprocess-corpus

(defn counted-tuples
  [parsed requests]
  (let [tuples (partition 2 1 parsed)
        first-node (first (first tuples))
        last-node (last (last tuples))
        counted (reduce
                 (fn [m [a b]]
                   (let [ac (.hashCode a)
