Fix trace generation bug