Optimized track distance calculations
Replaced gcdist with trkdist
Fixed typo