Bugfix/scrutinizer fixes

This PR introduces a few fixes recommended by scrutinizer