fix issue with Distance vs SquareDistance in kdtree