[4.14 / 4.9 / 4.4] backport of 2cea4a7a1885bd0c765089afc14f7ff0eb77864e and fe968c41ac4f4ec9ffe3c4cf16b72285f5e9674f