There's a lot of work in this PR that could get merged into master already. I'm fine with tackling the fine points in a separate PR to keep the discussion focused.