Fix memory leak in TMap.

Specifically targeting this at a release just after 3.0, which I'd like to use as a chance to focus on memory issues.