On second thought, we should be using these or quite similar functions. This reverts commit a44ef130.