Bugfixes: related with issues pointed by Valgrind;