Tracing

Upstreaming some of @waywardmonkeys's stuff.  Bruce, should this get merged?
This is a merge conflict (and is already upstream).