Implement more robust revision system and implement basic document api.