Many more optimizations for breadth first search.