applying patch from upstream svn commit r1723