Improved MC distance algorithm.