Restorable state machine