improved serial port setup and purge