added code to handle tx underrun and rx overflow.