added support for various document types, some refactoring