reorganizing the contexts
added support to legacy documents