Added patch from #2775