Adding threadings, and generating data in csv files.