Copy-pasted from lens-3.9.0.2