Use explicit casts to fix mac clang c++ compiler errors.