Fix issues found by Coverity scan