Added regularization for Mahalanobis distance.