Add explicit casts to make clang support easier - see #755