Altered link and findCentroid functions.