Separate makecsv command. Refactoring code.