Merge upstream DGI changes.  Add documentation and generally clean-up API.