Cleanup tracing implementation.

Problem before was not correctly using tracing scopes, leading to a scope
/trace never being closed (so the currentSpan was always set), and having
multiple commits all wrapped into a single trace (incorrectly).

Also, this handles 'orphan' spans more cleanly by ensuring that they are tracked
and picked up by later spans. This can happen is span timings are little off
(e.g. clocks are not perfectly synchronized or something goes wonky internally), but
still ensures that the span heirarchy is preserved.

Additionally, did some cleanup to printing a trace to help with debugging.