Fix issues found by Coverity Scan