Moved the code for pickling datasets to the Monitor class.