Fixed many memory leaks. Probably still tons left.