Bug fixes, adapted to use bed file again.