Fix errors found by Coverity