Fixed issues discovered by clang