Fix MSVC compiler warnings

This removes unused variables and redundant re-declarations to silence
warnings about variable shadowing. Tested on MSVC 14 CTP2.