   "Find a piled-up base and an indel from an alignment."
   [^long ref-pos ^SAMAlignment aln]
   (let [relative-pos (- ref-pos (.pos aln))
-        qual ((:quals-at-ref aln) relative-pos)
-        [base indel] ((:seqs-at-ref aln) relative-pos)
+        qual (aget ^shorts (:quals-at-ref aln) relative-pos)
+        ^PosBase pb (aget ^objects (:seqs-at-ref aln) relative-pos)
+        base (.base pb)
+        indel (.indel pb)
         deletion? (number? indel)]
     (plpio/->PileupBase
      (zero? relative-pos)

(defn- merge-corrected-quals
  "Merge corrected quals with the uncorrected part."
  [^SAMAlignment aln ^long correct-start corrected-quals]
  (let [quals (:quals-at-ref aln)
        start (.pos aln)
        len   (count corrected-quals)]
    (if (< start correct-start)
      (-> quals
          (subvec 0 (- correct-start start))
          (into corrected-quals)
          (into (subvec quals (+ (- correct-start start) len))))
      (into corrected-quals (subvec quals len)))))

(defn- correct-pair-qual
  [^SAMAlignment a1 ^SAMAlignment a2]
  (let [pos1 (.pos a1)
        pos2 (.pos a2)
        quals1 (:quals-at-ref a1)
        quals2 (:quals-at-ref a2)
        seqs1  (:seqs-at-ref a1)
        seqs2  (:seqs-at-ref a2)]
    (fn [^long pos]
      (let [relative-pos1 (- pos pos1)
            relative-pos2 (- pos pos2)
            ^int q1 (quals1 relative-pos1)
            ^int q2 (quals2 relative-pos2)
            [b1] (seqs1 relative-pos1)
            [b2] (seqs2 relative-pos2)]
        (if (= b1 b2)
          [(min 200 (+ q1 q2)) 0]
          (if (<= q2 q1)

  [^long min-base-quality]
  (fn [p]
    (->> #(<= min-base-quality (.qual ^PileupBase %))
         (partial filter)
         (update p 1))))

(defn- unzip-2
