Avoid warnings when building for iOS

Get rid of warnings by avoiding mixing data types unnecessarily,
and by adding casts.