Added ability to record parameters and stats to a text file.