Copied functions/classes from CSVReader, starting to integrate/merge