Fix integer overflow in baudrate setting.
Add debug functions.