kmeans: reverted to working version (hopefully)