backport a679168f511de6f15eb16eb3b111ed5bc3882c70 (#233)