Fixed export context switching and implemented support for ad-hoc hierarchies.