        (map (partial zipmap [:bin :chunks]))))
 
 (defn- init-linear-index []
-  {:index (gen-vec max-lidx-size 0)
-   :largest-seen -1})
+  {})
 
 (defn- update-linear-index
   [linear-index aln]
-  (let [{:keys [index largest-seen]} linear-index
-        {:keys [beg]} (:chunk (:meta aln))
+  (let [{:keys [beg]} (:chunk (:meta aln))
         aln-beg (:pos aln)
         aln-end (dec (+ aln-beg (cgr/count-ref (:cigar aln))))
         win-beg (if (zero? aln-end)

        win-end (if (zero? aln-end)
                  win-beg
                  (pos->lidx-offset aln-end))]
    (assoc linear-index
      :index (loop [i win-beg, lidx* index]
               (if (<= i win-end)
                 (let [l (nth lidx* i)]
                   (recur (inc i) (if (or (zero? l) (< beg l))
                                    (assoc lidx* i beg)
                                    lidx*)))
                 lidx*))
      :largest-seen (max win-end largest-seen))))

(defn- finish-linear-index
  "Optimizes the linear index for safety. This seems unnecessary, but samtools
  does this process."
  [linear-index]
  (let [{lidx :index, largest-lidx-seen :largest-seen} linear-index]
    (loop [i 0, lidx* [], last-non-zero 0]
      (if (<= i largest-lidx-seen)
        (let [l (long (nth lidx i))]
          (if (zero? l)
            (recur (inc i) (conj lidx* last-non-zero) last-non-zero)
            (recur (inc i) (conj lidx* l) l)))
        lidx*))))

(defn- init-index-status []
  {:meta-data    (init-meta-data)

       (make-index* refs)
       (finish-index refs)))

(defn make-index1
  [refs alns]
  (->> (partition-all 1000 alns)
