Rearranged AppDelegate