implement save/restore instance state