Fix a memory leak and optimize a little bit the generic path.

2 files changed