Fix #163 by guarding use of session scope in trace code.