Improved .sam file parser