unsigned long port;
        unsigned char val;
        static unsigned char last_data = 0;
+       static unsigned char last_write = 0x00;
        static unsigned char writebuf[USBBUFSIZE], *writepos = writebuf;
        static unsigned char readbuf[USBBUFSIZE], *readpos;
-       unsigned char data;
-       static unsigned char last_write = 0x00;
+       unsigned char data, prev_data;
 
-       /* Count writes */
+       /* Count reads */
        for (i = 0; i < num; i++)
-               if (tr[i].cmdTrans == 10)
+               if (tr[i].cmdTrans == PP_READ)
                        nread++;
 
        /* Write combining */
                i = 0;
                while (i < writepos-writebuf) {
                        i += ftdi_read_data(&ftdic, readbuf, sizeof(readbuf));
-               };
+               }
                DPRINTF("read %d/%d bytes\n", i, writepos-writebuf);
                writepos = writebuf;
        }
 
                /* Pad writebuf for read-commands in stream */
                *writepos = last_data;
+               prev_data = last_data;
 
                if (port == ppbase + PP_DATA) {
                        DPRINTF("data port\n");
                                        break;
                        }
                }
-               writepos++;
+
+               if (nread || (*writepos != prev_data))
+                       writepos++;
        }
 
        if (nread)