This reverts commit 272a57eeedb9593f06434b59a8765c4a2b715792, reapplying commit bb98ffbe7fc8d21f48286432fe685312fd9b07cc.