More reworking toward being useful as a library.
More refactoring to enable downstream Galaxy integration.