UART module refactoring