Fixes memory errors.
Total remaining compile errors: 3875
No memory leaks, no access violations.