Fixed alot of memory leaks.