Updated for iOS 6 support