   {:pre [(or (coll? rules) (nil? rules))
          (map? context)]
    :post [(boolean? %)]}
-  (loop [x rules]
-    (if (empty? x)
+  (loop [[x :as xs] rules]
+    (cond
       ;; Default to returning true if there is no match
-      true
-      (let [rule (first x)]
-        (if (rule-match? rule context)
-          (get rule "anonymize")
-          (recur (rest x)))))))
+      (empty? xs) true
+      (rule-match? x context) (get x "anonymize")
+      :else (recur (rest xs)))))
 
 ;; Functions for anonymizing the final leaf data
 (defn anonymize-leaf-value
   "Based on the input value, return an appropriate random replacement"
   [value]
   (cond
-   (string? value)            (random-string 30)
-   (integer? value)           (rand-int 300)
-   (float? value)             (rand)
-   (boolean? value)           (random-bool)
-   (vector? value)            (vec (map anonymize-leaf-value value))
-   (seq? value)               (seq (map anonymize-leaf-value value))
-   (map? value)               (zipmap (take (count value)
-                                            (repeatedly #(random-string 10)))
-                                      (vals (utils/update-vals value (keys value)
-                                                               anonymize-leaf-value)))
-   (nil? value)               nil
+   (string? value) (random-string 30)
+   (integer? value) (rand-int 300)
+   (float? value) (rand)
+   (boolean? value) (random-bool)
+   (vector? value) (mapv anonymize-leaf-value value)
+   (seq? value) (seq (map anonymize-leaf-value value))
+   (map? value) (zipmap (take (count value)
+                              (repeatedly #(random-string 10)))
+                        (vals (utils/update-vals value (keys value)
+                                                 anonymize-leaf-value)))
+   (nil? value) nil
    :else (random-string 30)))
 
 (def anonymize-leaf-memoize

  {:pre [(map? rule)
         (map? context)]
   :post [(boolean? %)]}
  (let [rule-context (get rule "context")
        context-keys (keys context)
        rule-keys    (keys rule-context)]
    (every? true?
            (for [k    rule-keys
                  :let [test  (get rule-context k)
                        value (get context k)]]
              (if (and (coll? value) (empty? value))
                false
                (matcher-match? test value))))))

  (let [[_ rel-type rel-title] (re-matches #"(.+)\[(.+)\]" rel)
        ;; here we modify the context, as the anonymization of a reference
        ;; is not about where it appears
        newcontext {"node" (get context "node")
                    "title" rel-title
                    "type" rel-type}
        ;; optionally anonymize each part
        new-type (anonymize-leaf rel-type :type newcontext config)
        new-title (anonymize-leaf rel-title :title newcontext config)]
    (str new-type "[" new-title "]")))

(defn anonymize-references
