add k-means clustering class + minor fixes