Added back threaded distance calculations to try to improve speed a bit