Revert previous patch; it was quite broken.