improvements to kmeans