Worked out all of the memory leaks that I could find