Some Coverity defect fixes

Fixed some funny coverity defects at the end of the day.