CSV file export added and correction of a few bugs