Refactor into multiple source files and more modular system for conversions and file handling

Also updated the API a bit.

Greg you should test this also because I almost definitely broke something.