some cleanup and documentation in Document.java