Refactoring.

* Add documentation comments to methods.
* Move the construction of the path to store the document to a standalone method.