Fixed infinite loop in Astar.