defer onrestore after closure deserialization to prevent infinite loop