insertEffects: fix global_capture

Late substitution of globals to deal with cyclic scope (to some degree)