fixed memory leaks, woohoo