Added centroid routine.
Fixed list index bug; added decent docstrings.