Fixed centroid-related bug