Added a configurable limit on the number of states. By default, 50000