convert old style casts to fix warnings

Sorry about all the blank lines changes. My editor removes trailing spaces on save.

This fixes a good chunk of the old style cast warnings.
Does this need the outer layer of parentheses?