Added patch from #2311