merged patrick's updates from SVN (up to r360)