Various small fixes picked up by Coverity Scan