Fixes after valgrind leak checks