Finished implementation of quality check and s.p. k-means.