improved rs232 kernel code