Factories to handle the comments and doc

add the new factories for DOC and ArrayOfComments
minor changes in the comment basefactory etc
changes in the algorithms