Fix errors

Fix Coverity errors and warnings