Changed to work with the SAM format.