fixing memory leak

verify the changes in this fix to re-enable full simuation.