Fixed unused variables.  Fixes #3749.

One of the unused variables was actually a bug... ooops
Merge pull request #3755 from WilkAndy/unused_3749

Fixed unused variables.  Fixes #3749.
Merge commit '22d5345304d0e0b913c16e3f688a1ebf7712b057'