Variable initialization, unused var removal, and casts.

Removed some unused variables to silence compiler warnings, initialized
variables to 0, added varialbe casts to silence additional compiler
warnings.