backport #2132 to maintenance