Fixed bug causing SA and GA distance to be calculated incorrectly