Clean up, add some tests
Cleanup in prepration for output to SQL database
Cleanup in prepration for output to SQL database