Backport #987