Switched to using a library for high quality csv parsing.  Cleaned up and customized the csv handling code.