ported latest changes from SVN tree