Memory Leaks Fixed update!

Found and fixed all memory leaks. Included debug functions for doing so