Major refactor into classes

Cleanup in prep for getting a bit more serious about doing this well.