Fix some memory leaks, hopefully