Refactor

Huge recode of every single file. Most of this stuff is over a year old now and not updated from the original prototype. This new foundation is in place for moving forward with the API and new UI powered by Twig.