Fixed the last remaining memory leaks