Committing in a collection of ongoing port work from #589636, so that we can stop trying to track it all in patches. Will make merging in changes (with an outside dvcs) from the 6--1 branch easier, anyway.