insertEffects: add tracing and fix global handling in createclosure