Trace improvements

@jodzga let's use this instead of the gc-fixes pull request. I'll delete that branch. This one includes everything in gc-fixes plus the trace improvements I was telling you about.