AppDelegate rewritten in Swift