Cleaned up the code and comments of ApplicationDelegate.