         (dotimes [j (alength iterators)]
           (.push iterator->present? false))))
     (dotimes [iterator (alength iterators)]
-      (let [iterator-vars (aget iterators iterator)]
+      (let [iterator-vars (aget iterator->vars iterator)]
         (dotimes [j (alength iterator-vars)]
           (let [var (aget iterator-vars j)]
-            (.push (aget var->iterators var) iterator)
+            (.push (aget var->iterators var) (aget iterators iterator))
             (aset var->iterator->present? var iterator true)))))
     (dotimes [i num-vars]
       (assert (> (alength (aget var->iterators i)) 0))
-      (.push var->intersection i (intersection (aget var->iterators i))))
+      (.push var->intersection (intersection (aget var->iterators i))))
     (let [join (Join. 0 iterators var->intersection var->iterator->present? false num-vars)]
       (.maintain join)
       join)))

  (assert (> num-vars 0))
  (dotimes [i (alength iterators)]
    (let [iterator-vars (aget iterator->vars i)]
      (assert (== (alength iterator-vars) (.key-len (aget iterators i))))
      (dotimes [j (alength iterator-vars)]
        (assert (< (aget iterator-vars j) num-vars)))))
  (let [var->iterators #js []

        (aset seek-key moving-key-ix (.key this))
        (.maintain this))
  (up [this]
      (assert (> moving-key-ix 0))
      (aset seek-key moving-key-ix greatest)
      (set! moving-key-ix pinned-key-ix)
      (set! pinned-key-ix (- pinned-key-ix 1))
      (set! pinned-key (when (>= pinned-key-ix 0) (aget seek-key pinned-key-ix)))
      (when (false? end?)
        (.seek iterator seek-key))
      (.maintain this))
  (mark [this]
        (.mark iterator))
