Trying to fix some memory leaks