Looks like this is the only code addition, the rest was just moved? Why was it moved, aesthetics or was something not working? (In terms of aesthetics, the nicest place is probably createContext, when setInModule is true.)

(Minor nit, indentation looks wrong here.)