Fix errors with serial port code