fixes #1, saving and restoring application state