Improved code style and updated for iOS 7.