Refactoring and kMeans Fixing Cost Optimization