Moved variables to global scope for cross-file tracing
Fixed trace ordering during callbacks