Minor bug fixes
Cleaned up export as CSV code