Fix bug in D2 handling
One more attempt at D2
Merge pull request #5 from hoerup/master

Make D2 work correctly