Cleaned up code for reading/writing csv - now using common data structures