Revert "Revert "Revert g9737584."" (but the fix) by reimplementing