Add two delegate methods to enable state saving and restoration.