Much more refactoring

* Moved script logic into objects
* Improved I/O cohesion
* Improved generality/symmetry in conversion functions
* Reorganized module structure