Fixed some of the memory errors, there are still a bunch more