Handling the Mahalanobis distance correctly.