CSV generation refactored.