Optmize data read and replace serial port with stream.