Fix compression of SAM/BAM files with a large number of optional fields.
Fix potential compile/link errors.