Backported r4240