Bug fixes in KMeans