Completed A* implementation.