Initial pathfinding code.