                                               stack-node-depths (inc depth)) (+ (cutoff (:queue b-sa)) b-rts)])
 ;                  _                   (println (apply str (repeat depth \ )) "Got " b-cd (:min-cycle-depth rec) (util/map-keys (juxt spos (comp :cycle-depth meta)) (:result-map rec)))
                   rec-mcd (if (< (:min-cycle-depth rec) depth) (:min-cycle-depth rec) *infinite-depth*)
-                  cd      (min b-cd)
+                  cd      (min b-cd rec-mcd)
                   result-nodes (for [[ss sr] (:result-map rec)
                                      :let [s-cd (min (:cycle-depth (meta ss)) b-cd)]]                                 
                                  (get-sanode-entry cache ss sr (next b-ra) (if (< s-cd depth) s-cd *infinite-depth*)))

            (queues/g-pq-replace! good-queue entry 
              (- (or (:cutoff (meta entry)) (:reward-to-state entry))))) ;(if-let [n  (:sanode entry)] (cutoff (:queue n)) 0)
          (.remove stack-node-depths node) ;; TODO: catchup!! 
;          (println "Returning from" (env/action-name (:action node)) (map #(env/get-var state %) '[[atx] [aty]]) "With cutoff" cut (cutoff good-queue) "and cdm" cutoff-depth-map "and states" (count new-results) (count catchup) "-" (count clean) (count dirtied) (count still-dirty) "and good roots" (count good-roots) (map :reward-to-state good-roots))
          (println (apply str (repeat depth \ )) "Returning from" (env/action-name (:action node)) (map #(env/get-var state %) '[[atx] [aty]]) "With cutoffs" cut (cutoff good-queue) ", ns"  (util/map-keys spos (stitch-effect-map catchup state reward-to-state) ) (count catchup) (count new-results))   
          (assert (<= (cutoff good-queue) init-cutoff))
          

        init  (env/initial-state e)
        root  (get-sa-node cache init (hierarchy/TopLevelAction e [(hierarchy/initial-plan henv)]))]
    (loop [cutoff 0 last-cutoff 0]
        (println "\ncutoff" cutoff "\n")
      (let [result (expand-sa-node root cache cutoff init 0.0 0 (IdentityHashMap.) 0)]
        (cond (not (empty? (:result-map result)))
                (let [[k v] (util/first-maximal-element val (:result-map result))]
