Fix various issues recommended by scrutinizer.