Changed so that the whole file is not always loaded when loading a document