Fixes in distance calculations.