some fixes for the memory leak