incremental improvements in solving the Mahalanobis segfault problem