Rewrite pepa.components.document to a more powerful style.
Rewrite pepa.components.document to a more powerful style.

We need that in a different branch anyway - sorry for throwing away some work.

rosund2/pepa,DR-YangLong/pepa,cswaroop/pepa,bevuta/pepa