 
 void falling() {
     attachInterrupt(0, rising, RISING);
+
+    //remember current time
+    //it will be used in raising function
     prev_time_falling = micros();
 
+    //calc length of last HIGH pulse
     pwm_high_length = micros() - prev_time_rising;
 
     if (state % 2 == 0) {
+        //We only can proceed is thate is even: 0, 2, 3 - after this state
+        //we always expect divider HIGH pulse to happen
         setState(state + 1, matchDivider(pwm_high_length));
     } else {
-        setState(state, false);
+        //Clear state to zero since it happens that we are in invalid state
+        //at this point
+        setState(0, true);
     }
 }
 


void fillDataArray(byte bitNumber, boolean isOne) {
    byte dataArrayIndex = bitNumber / BITS_PER_PACKET;
    data[dataArrayIndex] = (data[dataArrayIndex] << 1) | isOne;
}

void clearDataArray(byte upTo) {
    for (byte i = 0; i <= upTo; i++) {
        data[i] = 0;
    }
}

boolean matchDivider(int value) {
    return match(value, DIVIDER_PULSE_LENGTH, DIVIDER_THRESHOLD);
}

boolean matchStartBit(int value) {
    return match(value, START_BIT_LENGTH, START_BIT_THRESHOLD);
}

boolean matchOneBit(int value) {
    return match(value, BIT_1_LENGTH, REGULAR_BIT_THRESHOLD);
}

boolean matchZeroBit(int value) {
    return match(value, BIT_0_LENGTH, REGULAR_BIT_THRESHOLD);
}

boolean match(int value, int mathConst, int treshold) {
    return value > mathConst - treshold && value < mathConst + treshold;
}

void setState(byte st, boolean condition) {
    if (condition) {
        state = st;
    } else {
        state = 0;
        if (st > 3) {
            clearDataArray(((st - 2) / 2 - 1) / BITS_PER_PACKET);
        }
    }
}


    pwm_low_length = micros() - prev_time_falling;

    if (state % 2 == 0) {
        //Clear state to 0 since we are now in ivalid state
        setState(0, true);
    } else {
        if (state == 1) {
            //We expect start bit to match current LOW pulse
            setState(2, matchStartBit(pwm_low_length));
            return;
        }
