Edited serial handling to avoid serial buffer overflow.