Applied patch from #2807