remove unused local vars and redundant var
Merge pull request #4059 from shikolay/master

[OPEN] Minor clean ups