Mikhail's fix 3cec23f backported to 3.2.x.