minimal backport to fix bug from r9690