Full refactoring UART lib