WIP: restore state implementation, not compiled yet
WIP: implement restoreStateTransform function
WIP: finalize the implementation, compiles