Fix #1970 by adding some tracing and simple performance tracing