Patched memory leaks around exit() call.