Fix stuttery pathfinding; add lots more comments