Commented out write.csv to speed up.