Implemented some changes suggested by scrutinizer