         (if (=-state-sets (output-set inner-sp) (output-set o))
           (do (connect-and-watch! ret o child-watch)
               (summaries/summary-changed! ret))
-          (do (if (#{:SA :OS} (first (stub-name (stub o)))) 
+          (do (if (#{:SA :OS} (first (subproblem-name o))) 
                 (add-sp-child! ret o)
                 (connect-and-watch-stub! ret (make-output-collecting-stub (stub o)) #(add-sp-child! ret %)))))))    
     ret))

    (do (summaries/connect! p c false)
        (add-watcher! c f))))



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




;; TODO: collect children too ?
(declare make-output-collecting-subproblem)
(defn make-output-collecting-stub [inner-stub]
  (assert (not (= (first (stub-name inner-stub)) :OS)))
  (assert (not (= (first (stub-name inner-stub)) :SA)))
  (make-wrapping-stub
   [[:OS (stub-name inner-stub)] (input-set inner-stub)]
   inner-stub make-output-collecting-subproblem))


(defn =-state-sets [s1 s2]
