     (if (and (util/singleton? refs-results) (util/singleton? (ffirst refs-results)))
         (first (ffirst refs-results))
       (when (seq refs-results)
+        (assert (apply = (map util/keyset (map second refs-results)))) ;; Otherwise, no-effect not handled properly when not in PC.
         (SAS-VV-HLA var goal-val 
                     (set (for [[ref _] refs-results, a ref, v (precond-var-set a)] v))
                     init-sets 
                     (apply merge-with clojure.set/union (map second refs-results))
                     (map first refs-results))))))
 
-(defn induce-action-hla [a init-sets ]
+
+(defn induce-action-hla- [a init-sets ]
   (println "Inducing HLA for preconds + action" (:name a))
   (let [first-bits (for [[pvar pval] (:precond-map a)
                          :when (not (= (init-sets pvar) #{pval}))]
                      (induce-vv-hla pvar pval init-sets ))]
-;    (doall first-bits)
-;    (doseq [b first-bits] (println "\n" b "\n\n"))
+    (doall first-bits)
+;    (println (:name a) (count first-bits))
+;    (doseq [b first-bits] (println "\n" (env/action-name b) "\n\n"))
     (when (every? identity first-bits)
      (if (empty? first-bits)
          a

          (merge (effect-sets bit) (util/map-vals (fn [x] #{x}) (:effect-map a)))
          [[bit a]]))))))

(defn induce-hierarchy [sas-problem]
  (let [{:keys [vars actions init]} sas-problem]
    (binding [*vars*         vars
              *reverse-dtgs* (make-extended-reverse-dtgs vars actions)]
      (hierarchy/SimpleHierarchicalEnv sas-problem 
        [(util/make-safe 
          (induce-action-hla (util/safe-singleton (get-in *reverse-dtgs* [:goal [:true] [:false]]))
                             (util/map-vals (fn [x] #{x}) init)))]))))

(defmulti pretty-print-action type)

(defn pretty-print-hla [h]
  (println (str "\nRefs for HLA" (env/action-name h)) (precond-var-set h) (effect-sets h))
  (doseq [ref (:refinements h)]
    (println " " (util/str-join ", " (map env/action-name ref))))
  (doseq [ref (:refinements h), a ref]

        extended-rdtgs              (make-extended-reverse-dtgs vars actions)]
    (filter
     (fn [[[var1 val1] [var2 val2]]]
       (when (< (.compareTo #^Comparable var1 #^Comparable var2) 0)
         (every? (fn [[var val other-var other-val]]
                   (every? (fn [a] (not (= (get (:effect-map a) other-var other-val) other-val)))
                           (apply concat (vals ((extended-dtgs var) val)))))
