Some Coverity Fixes

This branch, so far, covers four Coverity bugs. One of them can't really be fixed, so I documented it in comments. The others that are currently in this branch are fairly straight-forward.