Backport #1044