(Hopefully) fixed some memory leaks