Fix bug in PDU flush/write code