Fixed a bunch of errors in the document algebra. Stuff works.