Convert to library

Admittedly, didn't make too many changes...

- Tried to make into more of a python package
- Did some cleanup
- Added some unit tests (by no means complete)