Some explicit casts to appease Xcode 5.1 with warnings as errors.