Fixed some small memory leaks