fixed distnace calculator
added saving for pathfinding mode preference