Fixes suggested by scrutinizer