Fixes problems uncovered by scrutinizer
Merge pull request #768 from nsendetzky/master

Fixes problems uncovered by scrutinizer