Backport #986