began refactoring and changed data structures in k-means calculation