Minor changes to the distance calculations