Add the basic design changes to use a chain instead of a stupid sed.

Needs more work. To be continued.

Change-Id: I68ef7f0b1e348f18adeadbd250ce63298ef36902