Fix up bugs in serial code after testing on hardware