Implemented file format check.
Added full support for custom document types.