MPU6050 erratic mode

I’m using a GY-521 MPU6050 module from ebay with an Arduino for a flight controller. The 6050 frequently gets into a mode giving crazy results until I re-initialize it. I tried replacing the 100nf cap. I’m polling the 6050 at ~30 ms. Does anyone know how to make it reliable? Here is the relevant code:

void loop() {
mpuIntStatus = mpu.getIntStatus();
fifoCount = mpu.getFIFOCount();
if ((mpuIntStatus & 0x10) || fifoCount == 1024) mpu.resetFIFO(); // Reset if overflow
if (mpuIntStatus & 0x02) { 
    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); 
    mpu.getFIFOBytes(fifoBuffer, packetSize);
    fifoCount -= packetSize;
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
    while (fifoCount > packetSize) { 
       mpu.getFIFOBytes(fifoBuffer, packetSize); 
       fifoCount = mpu.getFIFOCount(); } }
PitchDeg = (ypr[1] * 180/M_PI);

Which Arduino board do you use ?
Can you show the full sketch and tell which libraries you use ?

I found the solution with a new library:

These days buying chips on eBay carries a high risk of fakes, be warned...