Fix distance calculations.