 	    ;; window good so far, keep working on it
 	    (recur (rest walking-actual)
 		   (concat (:expected-skipped-over candidate) (rest walking-expected))
-		   expected-variants
+		   expected-permutations
 		   best-so-far
 		   (tack-on-to candidate
 			       :actual-found (first walking-actual)
 			       :expected-found (first walking-expected)))
 
 	    (not (empty? (rest walking-expected)))
-	    ;; Perhaps another value in the current expected variant will work.
+	    ;; Perhaps another value in the current expected permutation will work.
+	    ;; We can, after all, be in any order.
 	    (recur walking-actual
 		   (rest walking-expected)
-		   expected-variants
+		   expected-permutations
 		   best-so-far
 		   (tack-on-to candidate
 			       :expected-skipped-over (first walking-expected)))
 
 	    (not (empty? (rest walking-actual)))
+	    ;; OK, there's no match for this actual element in the whole expected.
 	    (if gaps-ok?
-	      ;; Current actual doesn't match anything expected. Lose it and
-	      ;; try other actuals on same expected variant.
+	      ;; Since gaps are OK, we can drop the bad actual element and look for next one.
 	      (recur (rest walking-actual)
-		     (first expected-variants)
-		     expected-variants
+		     (first expected-permutations)
+		     expected-permutations
 		     (better-of candidate best-so-far)
 		     candidate)
 
-	      ;; Current window didn't work. Slide it down, reusing same expected variant
+	      ;; Start again with a new actual: the tail of what we started with.
 	      (recur (rest (concat (:actual-found candidate) walking-actual))
-		   (first expected-variants)
-		   expected-variants
+		   (first expected-permutations)
+		   expected-permutations
 		   (better-of candidate best-so-far)
                    starting-candidate))
 	    
-	    (not (empty? (rest expected-variants)))
-	    ;; Can't slide window any further, so let's try another variant
+	    (not (empty? (rest expected-permutations)))
+	    ;; No more actual elements, and we still have no match. So try a
+	    ;; different permutation of the expected list. (This is required
+	    ;; because of matching functions.
             (recur actual
-                   (second expected-variants)
-		   (rest expected-variants)
+                   (second expected-permutations)
+		   (rest expected-permutations)
 		   (better-of candidate best-so-far)
                    starting-candidate)
 
-	    :else ; no variant left, window used up. give up.
+	    :else ; no permutation left, no smaller actuals to try. give up.
 	    (better-of candidate best-so-far)))))
-
-;; (defmethod seq-comparison #{:in-any-order}
-;;   [actual expected & kind]
-;;   (let [starting-candidate  {:actual-found [], :expected-found [],
-;; 			     :expected-skipped-over [], :expected expected }
-;; 	starting-expected-variants (all-expected-variants expected)]
-;;     (loop [walking-actual   actual
-;;            walking-expected (first starting-expected-variants)
-;; 	   expected-variants starting-expected-variants
-;;            best-so-far      starting-candidate
-;;            candidate        starting-candidate]
-
-;;       (cond (or (empty? walking-actual) (empty? walking-expected))
-;;             (better-of candidate best-so-far)
-
-;; 	    (extended-= (first walking-actual) (first walking-expected))
-;; 	    ;; window good so far, keep working on it
-;; 	    (recur (rest walking-actual)
-;; 		   (concat (:expected-skipped-over candidate) (rest walking-expected))
-;; 		   expected-variants
-;; 		   best-so-far
-;; 		   (tack-on-to candidate
-;; 			       :actual-found (first walking-actual)
-;; 			       :expected-found (first walking-expected)))
-
-;; 	    (not (empty? (rest walking-expected)))
-;; 	    ;; Perhaps another value in the current expected variant will work.
-;; 	    (recur walking-actual
-;; 		   (rest walking-expected)
-;; 		   expected-variants
-;; 		   best-so-far
-;; 		   (tack-on-to candidate
-;; 			       :expected-skipped-over (first walking-expected)))
-
-;; 	    (not (empty? (rest walking-actual)))
-;; 	    ;; Current window didn't work. Slide it down, reusing same expected variant
-;;             (recur (rest (concat (:actual-found candidate) walking-actual))
-;; 		   (first expected-variants)
-;; 		   expected-variants
-;; 		   (better-of candidate best-so-far)
-;;                    starting-candidate)
-	    
-;; 	    (not (empty? (rest expected-variants)))
-;; 	    ;; Can't slide window any further, so let's try another variant
-;;             (recur actual
-;;                    (second expected-variants)
-;; 		   (rest expected-variants)
-;; 		   (better-of candidate best-so-far)
-;;                    starting-candidate)
-
-;; 	    :else ; no variant left, window used up. give up.
-;; 	    (better-of candidate best-so-far)))))
-
-
-;; (defmethod seq-comparison #{:in-any-order :gaps-ok}
-;;   [actual expected & kind]
-;;   (let [starting-candidate  {:actual-found [], :expected-found [],
-;; 			     :expected-skipped-over [], :expected expected }
-;; 	starting-expected-variants (all-expected-variants expected)]
-;;     ;; (println "=============")
-;;     ;; (println actual expected)
-;;     ;; (println starting-expected-variants)
-    
-;;     (loop [walking-actual   actual
-;;            walking-expected (first starting-expected-variants)
-;; 	   expected-variants starting-expected-variants
-;;            best-so-far      starting-candidate
-;;            candidate        starting-candidate]
-;;       ;; (println "walking " walking-actual "of" walking-expected)
-;;       ;; (println "remainder " expected-variants)
-
-;;       (cond (or (empty? walking-actual) (empty? walking-expected))
-;;             (better-of candidate best-so-far)
-
-;; 	    (extended-= (first walking-actual) (first walking-expected))
-;; 	    ;; actual good so far, keep working on it
-;; 	    (recur (rest walking-actual)
-;; 		   (concat (:expected-skipped-over candidate) (rest walking-expected))
-;; 		   expected-variants
-;; 		   best-so-far
-;; 		   (tack-on-to candidate
-;; 			       :actual-found (first walking-actual)
-;; 			       :expected-found (first walking-expected)))
-
-;; 	    (not (empty? (rest walking-expected)))
-;; 	    ;; Perhaps another value in the current expected variant will work.
-;; 	    (recur walking-actual
-;; 		   (rest walking-expected)
-;; 		   expected-variants
-;; 		   best-so-far
-;; 		   (tack-on-to candidate
-;; 			       :expected-skipped-over (first walking-expected)))
-
-;; 	    (not (empty? (rest walking-actual)))
-;; 	    ;; Current actual doesn't match anything expected. Lose it and
-;; 	    ;; try other actuals on same expected variant.
-;;             (recur (rest walking-actual)
-;; 		   (first expected-variants)
-;; 		   expected-variants
-;; 		   (better-of candidate best-so-far)
-;;                    candidate)
-	    
-;; 	    (not (empty? (rest expected-variants)))
-;; 	    ;; Can't slide window any further, so let's try another variant
-;;             (recur actual
-;;                    (second expected-variants)
-;; 		   (rest expected-variants)
-;; 		   (better-of candidate best-so-far)
-;;                    starting-candidate)
-
-;; 	    :else ; no variant left, window used up. give up.
-;; 	    (better-of candidate best-so-far)))))
 
 (defmethod seq-comparison :strict-order
   [actual expected & kind]

		   expected
		   (better-of candidate best-so-far)
		   starting-candidate)))))


;; (defmethod seq-comparison #{}
;;   [actual expected & kind]
;;   (let [starting-candidate  {:actual-found [], :expected-found [], :expected expected }]
;;     ;; (println "=============")
;;     ;; (println actual expected)
    
;;     (loop [actual           actual
;; 	   walking-actual   actual
;;            walking-expected expected
;;            best-so-far      starting-candidate
;;            candidate        starting-candidate]
;;       ;; (println "walking " walking-actual "of" walking-expected)

;;       (cond (or (empty? walking-actual) (empty? walking-expected))
;;             (better-of candidate best-so-far)

;; 	    (extended-= (first walking-actual) (first walking-expected))
;; 	    ;; actual good so far, keep working on it
;; 	    (recur actual
;; 	           (rest walking-actual)
;; 		   (rest walking-expected)
;; 		   best-so-far
;; 		   (tack-on-to candidate
;; 			       :actual-found (first walking-actual)
;; 			       :expected-found (first walking-expected)))

;; 	    (not (empty? actual))
;; 	    ;; See if we can find something better later on.
;; 	    (recur (rest actual)
;; 		   (rest actual)
;; 		   expected
;; 		   (better-of candidate best-so-far)
;; 		   starting-candidate)))))


; Searches through particular types of actual results


	argmap `(hash-map ~@first-kvs)]
    `(merge-with conj ~hashmap ~argmap)))

(defn- all-expected-permutations [expected]
  (cond (not-any? extended-fn? expected)
	[expected]

