BFS and merge sort changes