Is also able to refactor some of the uglier code and introduces a framework that (suitably extended) could be useful in removing boilerplate elsewhere.