Basic stats (csv) output; restructured code in main.