Now correctly writing the current state to state.conf