Ported to 4.0.x.