Fixed some more memory leaks and maybe some errors more legible