This reverts commit 5db92502. Further to the early revert, the sanitizers have found something wrong with this.