fixes from SCA

Fixes for issues found by cppcheck and clang.