Fix a few bugs in reading sam file
Fix warnings