Fixed the heap cleanup.