fix bugs according to scrutinizer