resolves #46 refactor file processing

I've split this into two steps so that we have the history of the refactoring for reference.