Fixes in the memory managment