Update BFS and BFS2.