Fixed most k-means bugs