Corrects more obscure shadowed variables cases
Corrects more obscure shadowed variable cases 2
correct misc minor warnings
remove unused variables