Implement state variable save/restore.