Made some fixes based on scrutinizer recommendations