WIP: partially restoring state management.