bugfix for decoding serial, speedup