Refactored CSV reading/writing to output a header row, and to use DictReader/Writer where possible. Moved some constants to new constants module.