Working generic state count with basic functionality.