A user made patch for the bugged BFS utility function