Remove traces of old code-generation framework. Add comments, generally tidy up code. No logic changes.