Changed bfs to use a deque instead of the Queue, and fixed the maxrecursiondepth bug.