It seems this patch broke some buildbots, so reverting until I have had a chance to investigate. This reverts commit 6b90a688.