I made a whole ton of changes here. I don't remember them all off the top of my head, but I think the history is fairly clean and readable. It's a pretty huge redesign, but I don't think external API is broken hardly at all, it just looks completely different under the hood. I think it's a lot cleaner, easier to understand, and hopefully easier to modify.
This MR has the changes necessary to deal with a shadowfile, so to resolve merge conflicts, just use this code.