Patching memory leaks