Fixing the state setter behaviour. Everything appears to work now. Next is fixing the tests...