Copied from http://duplicati.googlecode.com/svn/tags/1.3.4/