Fixes after CppCheck

Fix of bugs, found by CppCheck tool