Fixes for issues found via Coverity static analysis.