Bugfix

A few fixes for things Coverity detected.