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.
It's functionally the same before and after, but logically yes, it should be inside the cast.