Code gets column order correct.

Improved and cleaned code to get the CSV headers in the correct
(desired and sensible) order.