Halfway commit for saving/restoring application state

  - Halfway commit implementing saving state of application and restoring it.