Added some error handling: Keyboard interrupt now cleanly exits the program and corrupted serial output triggers a device reset rather then a crash.