 ;;--------------------------------------------------------------------------------
 
 (defn- lhs-upsert [[old-lhs-index rhs-indeces old-joins] lhs-pk-key lhs-fk-keys lhs join-fn join-pk joined-model]
-  (let [new-lhs-indeces (lhs-assoc-2 old-lhs-index lhs-pk-key lhs-fk-keys lhs)
+  (let [new-lhs-indeces (lhs-assoc old-lhs-index lhs-pk-key lhs-fk-keys lhs)
 	joins (derive-joins rhs-indeces lhs-fk-keys lhs join-fn)
 	new-joins (reduce (fn [old-joins join] (assoc old-joins (join-pk join) join)) old-joins joins)]
     [[new-lhs-indeces rhs-indeces new-joins] (fn [_] (on-upserts joined-model joins))]))
 
 (defn- lhs-delete [[old-lhs-indeces rhs-indeces old-joins] lhs-pk-key lhs-fk-keys lhs join-fn join-pk joined-model]
-  (let [new-lhs-indeces (lhs-dissoc-2 old-lhs-indeces lhs-pk-key lhs-fk-keys lhs)
+  (let [new-lhs-indeces (lhs-dissoc old-lhs-indeces lhs-pk-key lhs-fk-keys lhs)
 	joins (derive-joins rhs-indeces lhs-fk-keys lhs join-fn)
 	new-joins (reduce (fn [old-joins join] (dissoc old-joins (join-pk join))) old-joins joins)]
     [[new-lhs-indeces rhs-indeces new-joins] (fn [_] (on-deletes joined-model joins))]))


(defn- rhs-upsert [[lhs-indeces old-rhs-indeces old-joins] i rhs-pk-key rhs-fk-key lhs-fk-keys rhs join-fn join-pk joined-model]
  (let [fk (rhs-fk-key rhs)
	new-rhs-indeces (rhs-assoc-2 old-rhs-indeces i rhs-pk-key fk rhs)
	lhses (lhses-get lhs-indeces i fk)
	joins (mapcat (fn [lhs] (derive-joins new-rhs-indeces lhs-fk-keys lhs join-fn)) lhses)
	new-joins (reduce (fn [old-joins join] (assoc old-joins (join-pk join) join)) old-joins joins)

  (let [fk (rhs-fk-key rhs)
	lhses (lhses-get lhs-indeces i fk)
	old-joins2 (mapcat (fn [lhs] (derive-joins old-rhs-indeces lhs-fk-keys lhs join-fn)) lhses)
	new-rhs-indeces (rhs-dissoc old-rhs-indeces i rhs-pk-key fk rhs)
	new-joins2 (mapcat (fn [lhs] (derive-joins new-rhs-indeces lhs-fk-keys lhs join-fn)) lhses)
	joins (remove (fn [i] (contains? (apply hash-set new-joins2) i)) old-joins2)
	new-joins (reduce (fn [old-joins join] (dissoc old-joins (join-pk join))) old-joins joins)
