This backports commit 7250990196 from the main branch (working on an unstable v0.4) to the v0.3 branch.
7250990196