Move context creation to hooks.