Move source map finalize code to context finalizer