Fix different issues found by Coverity