Fix casting bugs for XCode6b2