Improved new createDocument function and modified C_Document class to use it.