Refactoring of the document tool tab partial. Several enhancements.