     ; If no sufficient, use best; otherwise sort sufficient and take 5
     (map-vals
       (fn [{:keys [best best-agree sufficient]}]
-        (let [best-agree (if best-agree
-                           (finalize-cmt-stats (:tid best-agree) best-agree)
-                           best-agree)]
+        (let [best-agree (when best-agree
+                           (finalize-cmt-stats (:tid best-agree) best-agree))
+              best-head (cond
+                          best-agree [best-agree]
+                          best       [best]
+                          :else      [])]
+          (println best-agree)
+          ; If there weren't any matches of the criteria, just take the best match, and take the best agree if
+          ; possible, and if not just the best general
           (if (empty? sufficient)
-            ; If there weren't any matches of the criteria, just take the best match, and take the best agree if
-            ; possible, and if not just the best general
-            (if best-agree
-              [best-agree]
-              [best])
+            best-head
             (->> sufficient
                  ; Remove best agree if in list, since we'll be putting it in manually
                  (remove #(= best-agree %))
                  (repness-sort) ; sort by our complicated repness metric
-                 (concat [best-agree]) ; put best agree at front, regardless
+                 (concat (if best-agree [best-agree] [])) ; put best agree at front, if possible
                  (take 5) ; take the top 5
                  (agrees-before-disagrees))))))))
 

      (> (max rat rdt) current-best-z)))


(defn- beats-best-agrr?
  "Like beats-best-by-test?, but only considers agrees. Additionally, doesn't focus solely on repness,
  but also on raw probability of agreement, so as to ensure that there is some representation of what
  people in the group agree on. Also, note that this takes the current-best, instead of just current-best-z."
  [{:keys [ra rat pa pat] :as comment-conv-stats} current-best]
  (cond
    (and current-best (> (:ra current-best) 1.0))
        ; XXX - a litte messy, since we're basicaly reimplimenting the repness sort function
        (> (* ra rat pa pat) (apply * (map current-best [:ra :rat :pa :pat])))
    current-best
        (> (* pa pat) (apply * (map current-best [:pa :pat])))
    :else
        (or (> ra 1.0)
            (> pa 0.5))))


(defn passes-by-test?
  "Decide whether we should count a given comment-conv-stat hash-map as being representative."
  [{:keys [pat rat pdt rdt] :as comment-conv-stats}]
  (or (and (z-sig-90? rat) (z-sig-90? pat))

                  (gr-assoc gr :best (finalize-cmt-stats tid comment-conv-stats))
                  gr)
                ; Also keep track of best agree comment is, so we can throw that the front preferentially
                (if (beats-best-agr? comment-conv-stats (gr-get gr :best-agree))
                  (gr-assoc gr :best-agree (assoc comment-conv-stats :tid tid))
                  gr))))
          result
