Bug fixes on serial port