First lot of architectural changes.
Second lot of architectural changes.
Just move the code around for convenience.
Third lot of architectural changes.

Code ready for introduction of typing rule alternatives.