Clean up unused variables

Fixes issue #2859