silence some unused variable warnings and move some debug code to only execute in debug mode
Merge pull request #2969 from ZappoMan/silencewarnings

silence some unused variable warnings and move some debug code to only execute in debug mode