                  (let [left-done? (atom false)]
                    (fn [s b] 
                      (when (and (not @left-done?) (not (summary/live? (summaries/summary left-sp))))
-                       (reset! left-done? true) (println "BOO")
+                       (reset! left-done? true) #_(println "BOO" pair-stub left-sp right-sp (class right-sp))
                        (summaries/disconnect! s ss)
-                       (add-watcher! left-sp (fn [o] (def *sum* [s left-sp o]) (throw (RuntimeException. "Solved and children."))))
-                       (add-sp-child! s (make-nt-pair-subproblem subsuming-sp pair-stub left-sp right-sp)))
+                       (add-watcher! left-sp (fn [o] (def *sum* [s left-sp o])
+                                               (throw (RuntimeException. "Solved and children."))))
+                       ;; TODO: do more efficiently?
+                       (connect-and-watch! s (make-pair-stub2 subsuming-sp left-sp (stub right-sp))
+                                           (fn [os] (connect-and-watch! s os #(add-child-sp! s %))))
+ ;                       (add-sp-child! s (make-pair-subproblem subsuming-sp pair-stub left-sp right-sp))
+                       )
                      (or-summary s b))))             
              (fn [s ri] (make-pair-stub1 s (refine-input left-sp ri)
                           (subproblem-name right-sp) #(refine-input right-sp %)))

          
          (and subsuming-sp (not (terminal? subsuming-sp))) 
          (let [ret (make-simple-subproblem stub subsuming-sp out-set false or-summary ri-fn reward)]
            (doseq [c (get-atomic-sp-child-stubs ret)] ;; 
              (connect-and-watch! ret c
                (fn [sub-out]
                  (connect-and-watch! ret (refine-input sub-out inp-set) #(add-sp-child! ret %))
                  (summaries/summary-changed! ret)))) ;; TODO: needed?                       
            ret)
          
          :else 
          (let [ret (make-simple-subproblem stub subsuming-sp out-set false or-summary ri-fn reward)]
            (doseq [child (map #(make-fs-seq-stub inp-set %) (fs/child-seqs function-set inp-set))]
              (connect-and-watch! ret child #(add-sp-child! ret %)))
            ret))))




;;  (Since we don't keep only first solution)
(defn add-sp-child! [sp child-sp]
  (assert (not (terminal? sp)))
  (summaries/summary-changed-local! sp)
  (add-output! sp child-sp))


;; Note: All nonterminal subproblems use or-summary for ri-fn
