Factor out some repeated code in meta compiler.
Add some internal documentation.