Fix the state functionality, as it was broken