Fixed bugs in trace generator