Fix assorted compiler warnings.

Fix warnings about unused variables and shadowed variable names.