Fixed bugs found by Scrutinizer analysis