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.
Is this line correct? Should the `+ 1` be inside the cast, and does it need a cast at all?