Fixes against memory leaks