Fix bugs in serial bootloader