Backports to v0.4.x (#517) until c83355646e3b6d99fec3beb3bb85debde5cd098a