Initial checkin of KMeans implementation

Basic framework for KMeans implementation and code refactoring.