Refactoring and a little optimization of bam indexer