Took care of a lot of memory leaks - there's still a lot more though!