Fixed UART bugs, including infinite loop