Changed to breadth first search. Optimizations for breadth wide search.