This is incomplete work, and requires some minor tweeks to the integration tests which are not included in this commit.