This reverts commit 4fdd51b7. See the ticket for concerns with this implementation; it will be revisited. Backport of aabceadd from master