Re-introduce fix done in dac9b7 that was accidentally reverted in 0b2663.