Fix errors found by coverity scan