If there are multiple messages in PulseIn, on the first pass through the loop the first message is decoded correctly, but the _unparsed_pulses buffer is not cleared, resulting in decode failures for any more messages in PulseIn
This issue rarely comes up, since usually one read()s so often that PulseIn doesn't contain pulses for more than one message, but e.g. in REPL it behaves completely incorrectly.