Part of commit 94c48e791290ab39d958d329786e089a25854a14