No change in functionality.
This is almost entirely copy/paste, with the main exception of moving the
contents() method definitions out of the class definitions and moving the
needed TYPE definitions out of the header file.
Use git blame dd9a087 to follow the history before this refactoring.