 
 void fillDataArray(byte bitNumber, boolean isOne) {
     byte dataArrayIndex = bitNumber / BITS_PER_PACKET;
+    boolean isFirstBitInTetrad = bitNumber % 4 == 0;
+
+    if (isFirstBitInTetrad) {
+        //clear tetrad since it could be filled with random data
+        data[dataArrayIndex] = 0;
+    }
+
     data[dataArrayIndex] = (data[dataArrayIndex] << 1) | isOne;
 }
 
-void clearDataArray(byte upTo) {
-    for (byte i = 0; i <= upTo; i++) {
-        data[i] = 0;
-    }
-}
-
+// Matcher for divider bit
 boolean matchDivider(int value) {
     return match(value, DIVIDER_PULSE_LENGTH, DIVIDER_THRESHOLD);
 }
 
+// Matcher for start bit
 boolean matchStartBit(int value) {
     return match(value, START_BIT_LENGTH, START_BIT_THRESHOLD);
 }
 
+// Matcher for binary 1
 boolean matchOneBit(int value) {
     return match(value, BIT_1_LENGTH, REGULAR_BIT_THRESHOLD);
 }
 
+// Matcher for binary 0
 boolean matchZeroBit(int value) {
     return match(value, BIT_0_LENGTH, REGULAR_BIT_THRESHOLD);
 }
 
+//Whether pulse length value matches specified constant with specified threshold
 boolean match(int value, int mathConst, int treshold) {
     return value > mathConst - treshold && value < mathConst + treshold;
 }
 
+//set state to new value but only when condition is true
 void setState(byte st, boolean condition) {
-    if (condition) {
-        state = st;
-    } else {
-        state = 0;
-        if (st > 3) {
-            clearDataArray(((st - 2) / 2 - 1) / BITS_PER_PACKET);
-        }
-    }
-}
-
+    state = condition ? st : 0;
+}
+
+
+


void falling() {
    attachInterrupt(0, rising, RISING);
    prev_time_falling = micros();

    pwm_high_length = micros() - prev_time_rising;

    if (state % 2 == 0) {
        setState(state + 1, matchDivider(pwm_high_length));
    } else {
        setState(state, false);
    }
}


    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;
        }
