Fixed bug in state count by adding template variable.