Initial commit of count_states script. Functional but not yet fully hashed out.