Added buffer overflow flag while receiving data

"transmit" function now resets the line to TX after receiving data.
Also, made some clean up.