Added support for states to collect algorithm.