ported from private SVN