Following @trac-vdukhovni's comment, this MR backports to 9.0.2 some commits that were forgotten in 9.0.1.