Added handlers for shutdown to return the original values of serial port on program exit.
Removed sleep in main loop as it was causing loss of characters on the serial port.