major changes to mahalanobis functions. weights. j2k.