fixed all of the memory leaks so far