applying patch from upstream svn commit r1722