Rewrite codebase in order to implement a clearer and more extensible architecture. TODO: adapt the gist submodule to follow suit.