better handling of sub-contexts