Some bugfixes for the trace generation