add missing return statement
remove unused variables
use BAM output factory