Fixed warnings about selector ambiguity.

Added casts and temporary variables.