    (util/safe-get csp :var-pred-map)
    (util/safe-get csp :const-map)
    (map (util/safe-get csp :fluent-map-maker) allowed-pred-inst-maps)
-   {}))
+   {} r)
+  (seq r)))
 
 
 

	       pred
	       (rest (util/safe-get pred-instance-map pred-gen)) 
	       var-ordering
	       dummy-unary-var dummy-unary-val)])]
    (fn pred-map-maker [[true-tuple-map poss-tuple-map]]
      (util/map-map
       (fn [[pn map-maker]] [pn (map-maker true-tuple-map poss-tuple-map)])
       map-makers))))





; Returns new-domain
; TODO: change to use keyset
(defn filter-pos-domain [#^HashMap map pred domain]
;  (println "fpd" map pred domain)
  (util/intersection-coll domain (if-let [#^Map m (first (.get map pred))] (.keySet m) nil)))

;; TODO: make smarter?
(defn filter-neg-domain [map pred domain]
;  (println map pred domain)
  (let [sub (first (get map pred))]
    (reduce (fn [domain val] (if (true? (get sub val)) (disj domain val) domain)) domain domain)))
;  (util/difference domain (util/keyset (get map pred {}))))

;(defn simplify-map [#^HashMap map preds val]
;  (if (empty? preds) map
;    (let [#^HashMap m (.clone map)]
;      (doseq [pred preds]
;        (.put m pred (get (.get m pred) val)))
;      m))) 

(defn simplify-map [#^HashMap map preds val]
;  (println "simpl" map preds val)
  (doseq [pred preds]
    (let [sub (.get map pred)
	  fs (first sub)]
      (.put map pred (cons (get fs val) sub)))))


(defn unsimplify-map [#^HashMap map preds val]
  (doseq [pred preds]
    (.put map pred (rest (.get map pred)))))
;  (reduce (fn [map pred] (assoc map pred (get (get map pred) val)))
;	  map preds))


(defn- all-solutions [vars-left initial-domains var-map const-map clause-maps inst-map #^ArrayList results]
;  (println vars-left initial-domains var-map const-map clause-maps inst-map "\n\n")
  (if (empty? vars-left) (.add results inst-map);[inst-map]
    (let [[var arg?]    (first vars-left)
	  [pos-const neg-const pos-fluent neg-fluent] (util/safe-get var-map var)
	  const-domain 
