fix bam db and other bugs