Port changes from #2803