Fixed the memory leak problems.  Drastically changed the code and reduced the line count.  Now the program reads bam files in place, without mallocing any data structures in the user space