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.