imported from darcs