Changed the App event handling so now it actually works.
  (OnActivated, DidEnterBackground, WillEnterForeground,
   OnResignActivation, WillTerminate).

There is some trace messages that will have to be removed later.

App is not crashing anymore on some devices when app goes in the background,
but will still crash when it is back to the foreground. More work is needed.