This is really rough around the edges and needs a lot of testing.
Too much happened on this branch to summarise here.