Bugs fixed

Bugs suggested by Scrutinizer-CI fixed