(Improved) KMeans clustering algorithm