               (add-all-child-watcher! subsuming-sp
                 (fn [subsuming-child]
                   (let [can-subsuming-child (canonicalize subsuming-child)]
-                    (when (and (not (identical? can-child can-subsuming-child))
-                               (= (sp-name can-child) (sp-name can-subsuming-child)))
-                      #_(print ".")
-                      #_ (println [s subsuming-sp] "==>" [child subsuming-child])
+                    (when (= (sp-name can-child) (sp-name can-subsuming-child))
                       (when (add-subsuming-sp! can-child can-subsuming-child)
                         #_ (println [s subsuming-sp] "==>" [child subsuming-child])
                         )))))))))
       true))
   
-  (refine-input    [s ni] (let [ret (ri-fn s ni)] (util/assert-is (= nm (sp-name ret))) ret)))
+  (refine-input    [s ni]
+    (let [ret (ri-fn s ni)]
+      (util/assert-is (= nm (sp-name ret)))
+      (when (canonical? s) (add-subsuming-sp! ret s))
+      ret)))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Utils  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Generic Trait  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Canonical SPs are Atomic and Pair; wrappers use TS of inner SP.
(defn canonicalize [sp] (ts-sp (sp-ts sp)))
(defn canonical? [sp] (identical? sp (ts-sp (sp-ts sp))))

(traits/deftrait simple-subproblem
  [nm inp-set wrapped-ts eval!-fn ri-fn]
  [                 ts-atom          (atom wrapped-ts)
   ^PubSubHub       output-ps        (make-pubsubhub)
   ^PubSubHub       child-ps         (make-pubsubhub)
   ^PubSubHub       all-child-ps     (make-pubsubhub) ;; For sub-following -- remove if no help.
   ^IdentityHashMap subsuming-sp-set (IdentityHashMap.)]
  [summaries/simple-cached-node]
  Subproblem
  (sp-name             [s] nm)
  (input-set           [s] inp-set)
  (sp-ts               [s] (or @ts-atom (reset! ts-atom (make-tree-summarizer s))))


(defn make-wrapped-subproblem [nm inp-set prefix-set inner-sp output-wrap child-watch ri-fn]
  (util/assert-is (contains? prefix-set (first (sp-name inner-sp))))
  (let [ret (make-subproblem nm inp-set (sp-ts inner-sp) noeval ri-fn summaries/or-summary)]
    (connect-and-watch! ret inner-sp
      (fn [o] (set-output-set! ret (output-wrap o)))
      (fn [inner-child] (child-watch ret inner-child)))
    ret))

;; Note: summary-fn should take subsuming-bound into account.
(defn- make-simple-subproblem [nm inp-set ri-fn eval-fn summary-fn]
  (make-subproblem nm inp-set nil eval-fn (fn [s ni] (if (= ni inp-set) s (ri-fn s ni))) summary-fn))

;; Get a fresh subproblem with the given name and input.
(defmulti get-subproblem (fn get-subproblem-dispatch [nm inp] (first nm)))
