Fix some bugs in BFS2.