Fix some static analysis issues (coverity)