Adjusted sleep-mode code so that the APP_STATUS on leaving sleep-mode, would be set to the status which was set when the prepare sleep-mode signal was triggered(and other minor changes).