WIP: add save/restore-state flags