Finished kmeans implementation.