Cleaned up trace_wrap()