Reduce scope of variable
Check emptiness using empty
Reduce scope of variable
Merge pull request #1129 from hansjoachim/cppcheck-fixes

Cppcheck fixes