Fixed bugs regarding self.appDelegate