BFS for finding components - works, but some bugs((