Modified nistsimulation to clean memory at the end of each simulation