Canopy/KMeans-related code