Cleanup.
Added guard for memory tracking.