Further improvements for KMeans

Addition of "distortion" - calculates summed distortion of a given
clustering. Minor additional refactoring.
Whitespace cleanup