This reverts commit 64eb3a49. It caused miscompiles with optimizations enabled. Reverting while I investigate.