discovery.cpp porting completed to htslib and new reference iterator