Fixed centroid linkage algorithm + other fixes