Changed stateagent, needs testing
Stateagent improved