diff --git a/cores/arduino/Interrupts.cpp b/cores/arduino/Interrupts.cpp
index a01b79fa5..8b4629842 100644
--- a/cores/arduino/Interrupts.cpp
+++ b/cores/arduino/Interrupts.cpp
@@ -24,8 +24,7 @@
 #if EXT_INTERRUPTS_HOWMANY > 0
 
 extern const PinMuxCfg_t g_pin_cfg[];
-
-#define MAX_IRQ_CHANNEL (15)
+constexpr int MAX_IRQ_CHANNEL = 15;
 
 using IrqFuncVoid_f          = void (*)();
 using IrqFuncParam_f         = void (*)(void *);
@@ -43,13 +42,11 @@ class IrqPool {
   public:
   IrqPool() {}
   ~IrqPool() {
-    for(int i = 0; i < MAX_IRQ_CHANNEL; i++) {
-      if(irqs[i] != nullptr){
-        delete irqs[i];
-        irqs[i] = nullptr;
-      }
+   for (auto& irq : irqs) {
+    delete irq;
+    irq = nullptr;
     }
-  }
+   }
   CIrq *get(int index, bool make) { 
     if(index < MAX_IRQ_CHANNEL) {
         if(irqs[index] == nullptr && make) {
@@ -95,7 +92,7 @@ static void IrqCallback(external_irq_callback_args_t * p_args) {
     void * param = (void *)p_args->p_context;
     uint32_t ch = p_args->channel;
 
-    CIrq *irq_context = nullptr;
+    auto *irq_context = nullptr;
 
     if(ch < MAX_IRQ_CHANNEL) {
         irq_context = IrqChannel.get(ch,false);
@@ -118,8 +115,8 @@ static void IrqCallback(external_irq_callback_args_t * p_args) {
 void detachInterrupt(pin_size_t pinNumber) {
 /* -------------------------------------------------------------------------- */    
 
-    CIrq *irq_context = nullptr;
-    int ch = pin2IrqChannel(pinNumber);
+    auto *irq_context = nullptr;
+    const int ch = pin2IrqChannel(pinNumber);
     
     if(ch >= 0 && ch < MAX_IRQ_CHANNEL) {
         irq_context = IrqChannel.get(ch,false);
@@ -137,8 +134,8 @@ void detachInterrupt(pin_size_t pinNumber) {
 void attachInterruptParam(pin_size_t pinNumber, voidFuncPtrParam func, PinStatus mode, void* param) {
 /* -------------------------------------------------------------------------- */    
 
-    CIrq *irq_context = nullptr;
-    int ch = pin2IrqChannel(pinNumber);
+    auto *irq_context = nullptr;
+    const int ch = pin2IrqChannel(pinNumber);
     
     if(ch >= 0 && ch < MAX_IRQ_CHANNEL) {
         irq_context = IrqChannel.get(ch,true);
@@ -190,12 +187,12 @@ void attachInterruptParam(pin_size_t pinNumber, voidFuncPtrParam func, PinStatus
 }
 
 void attachInterrupt(pin_size_t pinNumber, voidFuncPtr func, PinStatus mode) {
-    attachInterruptParam(pinNumber, (voidFuncPtrParam)func, mode, NULL);
+    attachInterruptParam(pinNumber, (voidFuncPtrParam)func, mode, nullptr);
 }
 
 int attachIrq2Link(uint32_t pinNumber, PinStatus mode) {
-    CIrq *irq_context = nullptr;
-    int ch = pin2IrqChannel(pinNumber);
+    auto *irq_context = nullptr;
+    const int ch = pin2IrqChannel(pinNumber);
     
     if(ch >= 0 && ch < MAX_IRQ_CHANNEL) {
         irq_context = IrqChannel.get(ch,true);
@@ -248,8 +245,8 @@ int attachIrq2Link(uint32_t pinNumber, PinStatus mode) {
 int detachIrq2Link(pin_size_t pinNumber) {
 /* -------------------------------------------------------------------------- */    
 
-    CIrq *irq_context = nullptr;
-    int ch = pin2IrqChannel(pinNumber);
+    auto *irq_context = nullptr;
+    const int ch = pin2IrqChannel(pinNumber);
     
     if(ch >= 0 && ch < MAX_IRQ_CHANNEL) {
         irq_context = IrqChannel.get(ch,false);
diff --git a/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp
index b866046bb..9e70e1369 100644
--- a/cores/arduino/Tone.cpp
+++ b/cores/arduino/Tone.cpp
@@ -27,7 +27,7 @@ class Tone {
     }
 
     void start(void) {
-        if ((frequency != 0) && (channel != -1)) {
+        if (frequency != 0 && channel != -1) {
             tone_timer.start();
         }
         if (duration != 0) {
@@ -37,14 +37,14 @@ class Tone {
 
     void toggle() {
     	digitalWrite(pin, status);
-        status = !!!status;
+        status = !status;
         if (millis() > limit) {
             stop();
         }
     }
 
     void stop(void) {
-        if ((frequency != 0) && (channel != -1)) {
+        if (frequency != 0 && channel != -1) {
             tone_timer.stop();
         }
         digitalWrite(pin, LOW);
@@ -66,17 +66,19 @@ class Tone {
             }
         }
     }
-};
+}
 
 FspTimer Tone::tone_timer;
 int Tone::channel = -1;
-static Tone* active_tone = NULL;
+static Tone* active_tone = nullptr;
 
 void tone_timer_callback(timer_callback_args_t __attribute__((unused)) *args) {
-    active_tone->toggle();
+    if (active_tone) {
+        active_tone->toggle();
+    }
 }
 
-void tone(pin_size_t pin, unsigned int frequency, unsigned long duration) {
+void tone(pin_size_t pin, unsigned int frequency, unsigned long duration = 0) {
 	if (active_tone) {
 		if (active_tone->pin == pin && active_tone->frequency == frequency && active_tone->duration == 0) {
 			// infinite duration notes do not need to be restarted
@@ -87,12 +89,12 @@ void tone(pin_size_t pin, unsigned int frequency, unsigned long duration) {
 	Tone* t = new Tone(pin, frequency, duration);
 	active_tone = t;
 	t->start();
-};
+}
 
 void noTone(pin_size_t __attribute__((unused)) pin) {
 	if (active_tone) {
 		active_tone->stop();
 		delete active_tone;
-		active_tone = NULL;
+		active_tone = nullptr;
 	}
-};
+}
diff --git a/cores/arduino/digital.cpp b/cores/arduino/digital.cpp
index fceeb5d21..479a7937e 100644
--- a/cores/arduino/digital.cpp
+++ b/cores/arduino/digital.cpp
@@ -1,29 +1,33 @@
 #include "Arduino.h"
 
 void pinMode(pin_size_t pin, const PinMode mode) {
-	switch (mode) {
-		case INPUT:
-		case INPUT_PULLDOWN: // TODO: document the INPUT_PULLDOWN is unavailable
-			R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_INPUT);
-			break;
-		case INPUT_PULLUP:
-			R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_INPUT | IOPORT_CFG_PULLUP_ENABLE);
-			break;
-		case OUTPUT:
-			R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
-			break;
-		case OUTPUT_OPENDRAIN:
-			R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PMOS_ENABLE);
-			break;
-		}
+    switch (mode) {
+        case INPUT:
+        case INPUT_PULLDOWN: // TODO: document that INPUT_PULLDOWN is unavailable
+            R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_INPUT);
+            break;
+        case INPUT_PULLUP:
+            R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_INPUT | IOPORT_CFG_PULLUP_ENABLE);
+            break;
+        case OUTPUT:
+            R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
+            break;
+        case OUTPUT_OPENDRAIN:
+            #if defined(ARDUINO_UNO)
+            R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_NMOS_ENABLE);
+            #else
+            R_IOPORT_PinCfg(NULL, g_pin_cfg[pin].pin, IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PMOS_ENABLE);
+            #endif
+            break;
+    }
 }
 
 void digitalWrite(pin_size_t pin, PinStatus val) {
-	R_IOPORT_PinWrite(NULL, g_pin_cfg[pin].pin, val == LOW ? BSP_IO_LEVEL_LOW : BSP_IO_LEVEL_HIGH);
+    R_IOPORT_PinWrite(NULL, g_pin_cfg[pin].pin, val == LOW ? BSP_IO_LEVEL_LOW : BSP_IO_LEVEL_HIGH);
 }
 
 PinStatus digitalRead(pin_size_t pin) {
-	bsp_io_level_t ret;
-	R_IOPORT_PinRead(NULL, g_pin_cfg[pin].pin, &ret);
-	return (ret == BSP_IO_LEVEL_LOW ? LOW : HIGH);
+    bsp_io_level_t ret;
+    R_IOPORT_PinRead(NULL, g_pin_cfg[pin].pin, &ret);
+    return (ret == BSP_IO_LEVEL_LOW ? LOW : HIGH);
 }
diff --git a/libraries/RTC/src/RTC.cpp b/libraries/RTC/src/RTC.cpp
index 843af650c..9d947e039 100644
--- a/libraries/RTC/src/RTC.cpp
+++ b/libraries/RTC/src/RTC.cpp
@@ -295,6 +295,9 @@ bool RTCTime::setYear(int _y) {
     if (_y >= TM_YEAR_OFFSET) {
         _y -= TM_YEAR_OFFSET;
     }
+    if (_y < 0 || _y > 99) {  // Valid range for RTC is 2000-2099
+       return false;
+    }
     year = _y;
     stime.tm_year = _y;
     //stime.tm_yday = day + yday(year, Month2tm(month));
@@ -345,6 +348,9 @@ bool RTCTime::setSaveLight(SaveLight sl) {
 bool RTCTime::setUnixTime(time_t time) {
     struct tm *t;
     t = localtime(&time);
+    if (t->tm_year < 100 || t->tm_year > 199) {  
+        return false;
+    }
     setTM(*t);
     return true;
 }
@@ -715,4 +721,3 @@ bool RTClock::setTimeIfNotRunning(RTCTime &t) {
 RTClock RTC;
 #endif
 
-
diff --git a/libraries/WiFiS3/src/WiFiTypes.h b/libraries/WiFiS3/src/WiFiTypes.h
index 70be019a5..b1e396055 100644
--- a/libraries/WiFiS3/src/WiFiTypes.h
+++ b/libraries/WiFiS3/src/WiFiTypes.h
@@ -1,6 +1,17 @@
 #ifndef WIFI_S3_TYPES_H
 #define WIFI_S3_TYPES_H
 
+#define WL_SSID_MAX_LENGTH 32
+#define WL_WPA_KEY_MAX_LENGTH 63
+#define WL_WEP_KEY_MAX_LENGTH 13
+#define WL_MAC_ADDR_LENGTH 6
+#define WL_IPV4_LENGTH 4
+#define WL_NETWORKS_LIST_MAXNUM	10
+#define	MAX_SOCK_NUM 4
+#define SOCK_NOT_AVAIL 255
+#define NA_STATE -1
+#define WL_MAX_ATTEMPT_CONNECTION 10
+
 typedef enum {
    WL_NO_SHIELD = 255,
         WL_NO_MODULE = WL_NO_SHIELD,
@@ -31,4 +42,4 @@ enum wl_enc_type {
     ENC_TYPE_UNKNOWN = 255
 };
 
-#endif
\ No newline at end of file
+#endif