Fixed memory leaks
forgot half the files I'm very good at this