Re-applies bad2db31b7b256e7b26f60e18dd2301cd277880c. This reverts commit f84aef11a4cea741b68e2966f5f189320708bc60.