Made some minor alterations to the centroids() routine