Cleaning up BFS.