Organized code for expansion. Fixed serial port startup issue.