First version of pathfinding.