Restores and improves distance calculations.