code formatting and comments
added saving and restoring state to the Main
activity stack management