Refactor bam reader