Refactored usage of SerialPort, to allow for more generic port implementations.