More coverity fixes

Misc stuff, please review.