Downsample a BAM file by tag. Plus minor refactoring.