serial port handling improvements