[WIP] Refactor

Now that a proof of concept is finished, this tries to clean up and make it easier to work with.