Add beginning of CRUD-style API for documents
Some restructuring to eliminate "throw" as the method of reporting errors