Fix some warnings found with Coverity

This should bring us down to 14 outstanding defects.