Added support for intermediate documents