Restructured kmean implementation into a class.