Minor refactorings following the last commit for KMeans

Refactored the common function into a Functions util class. 
Oh sure, pick a different class name. MLFunctions. Anything really