Backport #391