backport from whiterussian [1371]