modified fix-memory-leaks.diff patch