Fix trace bugs