kmeans stuff in a more finished state