Trying to remove a memory leak