Add code to save/restore instance state