Hash aware input format

Here is my first pass at this. I'm not even sure it compiles, but it outlines the logic. Compilation and some tests are up next.

Don't merge this, obv.