some fixes to scaling distance