Fix TX state machine and miscellaneous other bits.