fix memory leaks. Yay