   }
 
   /* Listens for switch events */
-  Switch.listener();
-  ExternalSwitch.listener();
-
-  /* One of the Multifunction switches pressed for 10 seconds */
-  if ((Switch.getFunctionality() == SWITCH_MULTI && Switch.is10s()) ||
-      (ExternalSwitch.getFunctionality() == SWITCH_MULTI &&
-       ExternalSwitch.is10s())) {
-    Device.getMode() == MODE_NORMAL ? Device.reboot(MODE_ACCESS_POINT)
-                                    : Device.reboot(MODE_NORMAL);
-  }
-
-  /* One of the Multifunction switches pressed for 5 seconds */
-  if ((Switch.getFunctionality() == SWITCH_MULTI && Switch.is5s()) ||
-      (ExternalSwitch.getFunctionality() == SWITCH_MULTI &&
-       ExternalSwitch.is5s())) {
-    Device.getMode() == MODE_NORMAL ? Device.reboot(MODE_CONFIGURATION)
-                                    : Device.reboot(MODE_NORMAL);
-  }
-
-  Pir.listener();
+  for (uint8_t i = 0; i < 5; i++) {
+    if (Device.configuration.isSwitch[i]) {
+      Switch[i].listener();
+    }
+  }
+
+  for (uint8_t i = 0; i < 5; i++) {
+    if (Device.configuration.isSwitch[i]) {
+      /* One of the Multifunction switches pressed for 10 seconds */
+      if (Switch[i].getFunctionality() == SWITCH_MULTI) {
+        if (Switch[i].is10s()) {
+          Device.getMode() == MODE_NORMAL ? Device.reboot(MODE_ACCESS_POINT)
+                                          : Device.reboot(MODE_NORMAL);
+        } else if (Switch[i].is5s()) {
+          Device.getMode() == MODE_NORMAL ? Device.reboot(MODE_CONFIGURATION)
+                                          : Device.reboot(MODE_NORMAL);
+        }
+      }
+    }
+  }
+
+  for (uint8_t i = 0; i < 4; i++) {
+    if (Device.configuration.isPIR[i]) {
+      Pir[i].listener();
+    }
+  }
 
   Led.loop();
 }

  }

  /* Initializing relay and setting it's default state at power on*/
  if (Device.getMode() == MODE_NORMAL && Device.configuration.isRelay[0]) {
    Relay.begin(0);
    Relay.setRelayAfterRestoringPower();
  }

  /* Initialzing network */

  }

  /* Initializing Switches */
  for (uint8_t i = 0; i < 5; i++) {
    if (Device.configuration.isSwitch[i]) {
      Switch[i].begin(i);
    }
  }

  /* Initializing PIRs */
  for (uint8_t i = 0; i < 4; i++) {
    if (Device.configuration.isPIR[i]) {
      Pir[i].begin(i);
    }
  }

  /* Initializing MQTT */
  if (Device.getMode() != MODE_ACCESS_POINT && Device.configuration.mqttAPI) {
