Fix some issues found by static analysis.