   (expand-node        [se new-threshold]
     "Returns PartialResult of SearchNodes."))
 
-(defn make-goal-node [goal-state]
-  (reify SearchNode
-       (extract-goal-state [] goal-state)
-       (expand-node        [min-reward] (throw (UnsupportedOperationException.)))))
+(deftype GoalNode [goal-state]
+  SearchNode
+   (extract-goal-state [] goal-state)
+   (expand-node        [min-reward] (throw (UnsupportedOperationException.))))
 
 ;; Named node is simple non-terminal node whose equality semantics are given by name.
 (deftype NamedNode [name root-sa expand-fn] :as this

                  (let [{:keys [result-pairs max-reward]} (next-partial-solution search-problem min-reward)]
                    (reset! next-reward-atom max-reward)
                    ;; TODO: remove!
                    (doseq [x1 @result-vec-atom x2 result-pairs] (assert (not (= (first x1) (first x2)))))
                    (swap!  result-vec-atom into result-pairs)
                    (recur min-reward))
                (PartialResult nil @next-reward-atom)))))))))

            (if (< @index-atom (count @result-vec-atom))
                (let [[_ rew :as result] (nth @result-vec-atom @index-atom)]
                 ;; TODO: remove
;                  (util/assert-is (<= (count @result-vec-atom) 1) "%s" [@result-vec-atom])
                  (if (>= rew min-reward)
                      (do (swap! index-atom inc) 
                          (PartialResult [result] 
