Backport 1821

backport of  #1821