Backporting fix from SVN