Fixes for issues picked up by scrutinizer