Fixed a bug where calling the appdelegate from appstate threw exception