Refactor AppDelegate methods