Cleaned up code by extracting SerialPort to a global field.