export_data management command, code cleanup