Csv dd cleanup refactor (overrides PR #90 and #97)

This is a new PR that is the merge of PR #90 and #97, so it overrides them.