Fixes for iOS 8. Thanks to @asprega.