Added cluster-counting algorithm.