diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 03146ac7a439244d8057f6e9ae5d660f075b85e3..4a024243208667a5bfb2bfc8c19698d96d4f0f1a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,15 +1,12 @@
+variables:
+  SOURCE_FOLDER: "src"
+  CFLAGS: "-DINCLUDE_PORT_TRIGGER"
+
 include:
   - project: 'iopsys/gitlab-ci-pipeline'
     file: '/static-code-analysis.yml'
-    ref: '0.31'
+    ref: '1.2'
 
 stages:
     - static_code_analysis
 
-variables:
-  DEBUG: 'TRUE'
-  SOURCE_FOLDER: "./src"
-  FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
-  CPPCHECK_OPTIONS: "--enable=all --error-exitcode=1"
-  COMPILE: "./gitlab-ci/compile.sh"
-
diff --git a/gitlab-ci/install-dependencies.sh b/gitlab-ci/install-dependencies.sh
new file mode 100755
index 0000000000000000000000000000000000000000..285cc185721796dab4b7e8dba2c5292c8a88c21f
--- /dev/null
+++ b/gitlab-ci/install-dependencies.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+echo "install dependencies for tests"
+source ./gitlab-ci/shared.sh
+
+# install bbfdm
+install_bbfdm
diff --git a/gitlab-ci/shared.sh b/gitlab-ci/shared.sh
index f098751729cd67463d6d4912bc1bf7ffab42ee40..dc606510de3df2aea40656ed8fb4bd4c8a414169 100644
--- a/gitlab-ci/shared.sh
+++ b/gitlab-ci/shared.sh
@@ -13,7 +13,7 @@ function exec_cmd()
 
 function install_bbfdm()
 {
-	[ -d "/opt/dev/bbfdm" ] && rm -rf /opt/dev/bbfdm
+	[ -d "/opt/dev/bbfdm" ] && return 0
 
 	if [ -n "${BBFDM_BRANCH}" ]; then
 		exec_cmd git clone -b ${BBFDM_BRANCH} https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm
diff --git a/src/firewall.c b/src/firewall.c
index f962b22b86f1996d632813bd7a5925118ce9d02e..65128d4767ee0eec20db63af61569b781c3518af 100644
--- a/src/firewall.c
+++ b/src/firewall.c
@@ -21,7 +21,7 @@ struct rule_sec
 /*************************************************************
 * COMMON FUNCTIONS
 **************************************************************/
-static void firewall__create_zone_section(char *s_name)
+static void firewall__create_zone_section(const char *s_name)
 {
 	struct uci_section *s = NULL;
 	char *input = NULL;
@@ -43,7 +43,7 @@ static void firewall__create_zone_section(char *s_name)
 }
 
 
-static bool firewall_zone_exists(char *s_name)
+static bool firewall_zone_exists(const char *s_name)
 {
 	struct uci_section *s = NULL;
 
@@ -95,7 +95,8 @@ static void free_firewall_config_dup_list(struct list_head *dup_list)
 	}
 }
 
-void synchronize_firewall_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, bool is_dynamic_rule, struct list_head *dup_list)
+void synchronize_firewall_sections_with_dmmap(const char *package, const char *section_type, const char *dmmap_package,
+		bool is_dynamic_rule, struct list_head *dup_list)
 {
 	struct uci_section *s, *stmp, *dmmap_sect;
 	char *v;
@@ -227,24 +228,8 @@ static int addService(char *refparam, struct dmctx *ctx, void *data, char **inst
 
 static int delService(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *s = NULL, *stmp = NULL;
-
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			uci_foreach_sections_safe("firewall", "service", stmp, s) {
-				struct uci_section *dmmap_section = NULL;
-
-				get_dmmap_section_of_config_section("dmmap_firewall", "service", section_name(s), &dmmap_section);
-				dmuci_delete_by_section(dmmap_section, NULL, NULL);
-
-				dmuci_delete_by_section(s, NULL, NULL);
-			}
-			break;
-	}
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -370,6 +355,7 @@ static int browseRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_d
 
 		upnp_lease_file = DM_STRLEN(upnp_lease_file) ? upnp_lease_file : UPNP_LEASE_FILE;
 
+		// cppcheck-suppress cert-MSC24-C
 		FILE *fp = fopen(upnp_lease_file, "r");
 		if (fp == NULL)
 			return 0;
@@ -502,35 +488,28 @@ static int add_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char
 
 static int delete_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
+	struct rule_sec *rule = (struct rule_sec *)(((struct dm_data *)data)->additional_data);
 	struct uci_section *s = NULL;
 	char *order = NULL, *rules_num = NULL;
 	char buf[8] = {0};
-	struct dm_data *p = (struct dm_data *)data;
-	struct rule_sec *rule = (struct rule_sec *)(p->additional_data);
 
-	switch (del_action) {
-		case DEL_INST:
-			if (rule->is_dynamic_rule) {
-				bbfdm_set_fault_message(ctx, "This is a dynamic 'Rule' instance, therefore it's not permitted to delete it.");
-				return FAULT_9003;
-			}
+	if (rule->is_dynamic_rule) {
+		bbfdm_set_fault_message(ctx, "This is a dynamic 'Rule' instance, therefore it's not permitted to delete it.");
+		return FAULT_9003;
+	}
 
-			s = get_dup_section_in_dmmap_opt("dmmap_firewall", "chain", "creator", "Defaults");
-			dmuci_get_value_by_section_string(s, "rules_num", &rules_num);
+	s = get_dup_section_in_dmmap_opt("dmmap_firewall", "chain", "creator", "Defaults");
+	dmuci_get_value_by_section_string(s, "rules_num", &rules_num);
 
-			dmuci_get_value_by_section_string(p->dmmap_section, "order", &order);
-			update_rule_order(order, rules_num, false);
+	dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "order", &order);
+	update_rule_order(order, rules_num, false);
 
-			// Update rules number
-			snprintf(buf, sizeof(buf), "%lu", DM_STRTOUL(rules_num) - 1);
-			dmuci_set_value_by_section(s, "rules_num", buf);
+	// Update rules number
+	snprintf(buf, sizeof(buf), "%lu", DM_STRTOUL(rules_num) - 1);
+	dmuci_set_value_by_section(s, "rules_num", buf);
 
-			dmuci_delete_by_section(p->config_section, NULL, NULL);
-			dmuci_delete_by_section(p->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			break;
-	}
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -553,24 +532,8 @@ static int addObjFirewallDMZ(char *refparam, struct dmctx *ctx, void *data, char
 
 static int delObjFirewallDMZ(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *s = NULL, *stmp = NULL;
-
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			uci_foreach_sections_safe("firewall", "dmz", stmp, s) {
-				struct uci_section *dmmap_section = NULL;
-
-				get_dmmap_section_of_config_section("dmmap_dmz", "dmz", section_name(s), &dmmap_section);
-				dmuci_delete_by_section(dmmap_section, NULL, NULL);
-
-				dmuci_delete_by_section(s, NULL, NULL);
-			}
-			break;
-	}
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -585,25 +548,25 @@ static int get_firewall_enable(char *refparam, struct dmctx *ctx, void *data, ch
 
 static int get_firewall_config(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "Advanced";
+	*value = dmstrdup("Advanced");
     return 0;
 }
 
 static int get_firewall_advanced_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "Device.Firewall.Level.1";
+	*value = dmstrdup("Device.Firewall.Level.1");
     return 0;
 }
 
 static int get_firewall_level_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "1";
+	*value = dmstrdup("1");
 	return 0;
 }
 
 static int get_firewall_chain_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "1";
+	*value = dmstrdup("1");
     return 0;
 }
 
@@ -616,7 +579,7 @@ static int get_firewall_service_number_of_entries(char *refparam, struct dmctx *
 
 static int get_firewall_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "Stateful";
+	*value = dmstrdup("Stateful");
 	return 0;
 }
 
@@ -642,7 +605,7 @@ static int get_level_description(char *refparam, struct dmctx *ctx, void *data,
 
 static int get_level_chain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "Device.Firewall.Chain.1";
+	*value = dmstrdup("Device.Firewall.Chain.1");
 	return 0;
 }
 
@@ -658,14 +621,14 @@ static int get_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, voi
 
 			dmuci_get_value_by_section_string(s, "enabled", &enable);
 			if (*enable == '0') {
-				*value = "1";
+				*value = dmstrdup("1");
 				break;
 			}
 		}
 	}
 
 	if (portmapping_sec_exists == false)
-		*value = "1";
+		*value = dmstrdup("1");
 
 	return 0;
 }
@@ -678,11 +641,11 @@ static int get_level_default_log_policy(char *refparam, struct dmctx *ctx, void
 	uci_foreach_sections("firewall", "zone", s) {
 		dmuci_get_value_by_section_string(s, "log", &v);
 		if (*v == '1') {
-			*value = "1";
+			*value = dmstrdup("1");
 			return 0;
 		}
 	}
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -692,7 +655,7 @@ static int get_level_default_policy(char *refparam, struct dmctx *ctx, void *dat
 
 	dmuci_get_option_value_string("firewall", "@defaults[0]", "input", &input);
 	if (!input || *input == 0) {
-		*value = "Drop";
+		*value = dmstrdup("Drop");
 		return 0;
 	}
 
@@ -702,7 +665,7 @@ static int get_level_default_policy(char *refparam, struct dmctx *ctx, void *dat
 
 static int get_chain_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "1";
+	*value = dmstrdup("1");
 	return 0;
 }
 
@@ -741,7 +704,7 @@ static int get_rule_enable(char *refparam, struct dmctx *ctx, void *data, char *
 	struct rule_sec *rule_args = (struct rule_sec *)(p->additional_data);
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "1";
+		*value = dmstrdup("1");
 	} else {
 		char *v;
 
@@ -759,7 +722,7 @@ static int get_rule_status(char *refparam, struct dmctx *ctx, void *data, char *
 	struct rule_sec *rule_args = (struct rule_sec *)(p->additional_data);
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "Enabled";
+		*value = dmstrdup("Enabled");
 	} else {
 		char *v;
 
@@ -820,22 +783,22 @@ static int get_rule_target(char *refparam, struct dmctx *ctx, void *data, char *
 	struct rule_sec *rule_args = (struct rule_sec *)(p->additional_data);
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "Accept";
+		*value = dmstrdup("Accept");
 	} else {
 		char *target;
 
 		dmuci_get_value_by_section_string(p->config_section, "target", &target);
 		if (DM_STRLEN(target) == 0) {
-			*value = "Accept";
+			*value = dmstrdup("Accept");
 		} else {
 			if (strcasecmp(target, "Accept") == 0)
-				*value = "Accept";
+				*value = dmstrdup("Accept");
 			else if (strcasecmp(target, "Reject") == 0)
-				*value = "Reject";
+				*value = dmstrdup("Reject");
 			else if (strcasecmp(target, "Drop") == 0)
-				*value = "Drop";
+				*value = dmstrdup("Drop");
 			else if (strcasecmp(target, "MARK") == 0)
-				*value = "Return";
+				*value = dmstrdup("Return");
 			else
 				*value = target;
 		}
@@ -851,7 +814,7 @@ static int get_rule_log(char *refparam, struct dmctx *ctx, void *data, char *ins
 	struct rule_sec *rule_args = (struct rule_sec *)(p->additional_data);
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "0";
+		*value = dmstrdup("0");
 	} else {
 		char *v;
 
@@ -868,7 +831,7 @@ static int get_FirewallChainRule_CreationDate(char *refparam, struct dmctx *ctx,
 	struct rule_sec *rule_args = (struct rule_sec *)(p->additional_data);
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "0001-01-01T00:00:00Z";
+		*value = dmstrdup("0001-01-01T00:00:00Z");
 	} else {
 		*value = dmuci_get_value_by_section_fallback_def(p->dmmap_section, "creation_date", "0001-01-01T00:00:00Z");
 	}
@@ -896,7 +859,7 @@ static int get_FirewallChainRule_ExpiryDate(char *refparam, struct dmctx *ctx, v
 		strftime(expiry, sizeof expiry, "%Y-%m-%dT%H:%M:%SZ", gmtime(&time_value));
 		*value = dmstrdup(expiry);
 	} else {
-		*value = "9999-12-31T23:59:59Z";
+		*value = dmstrdup("9999-12-31T23:59:59Z");
 	}
 
 	return 0;
@@ -979,7 +942,7 @@ static int get_rule_source_all_interfaces(char *refparam, struct dmctx *ctx, voi
 	struct rule_sec *rule_args = (struct rule_sec *)(p->additional_data);
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "0";
+		*value = dmstrdup("0");
 	} else {
 		char *v;
 
@@ -1043,7 +1006,7 @@ static int get_rule_dest_all_interfaces(char *refparam, struct dmctx *ctx, void
 	struct rule_sec *rule_args = (struct rule_sec *)(p->additional_data);
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "0";
+		*value = dmstrdup("0");
 	} else {
 		char *v;
 
@@ -1061,17 +1024,17 @@ static int get_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, c
 	struct rule_sec *rule_args = (struct rule_sec *)(p->additional_data);
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "-1";
+		*value = dmstrdup("-1");
 	} else {
 		char *ipversion;
 
 		dmuci_get_value_by_section_string(p->config_section, "family", &ipversion);
 		if (strcasecmp(ipversion, "ipv4") == 0) {
-			*value = "4";
+			*value = dmstrdup("4");
 		} else if (strcasecmp(ipversion, "ipv6") == 0) {
-			*value = "6";
+			*value = dmstrdup("6");
 		} else {
-			*value = "-1";
+			*value = dmstrdup("-1");
 		}
 	}
 
@@ -1107,7 +1070,7 @@ static int get_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, cha
 	char *pch, *destip;
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "";
+		*value = dmstrdup("");
 		return 0;
 	}
 
@@ -1135,7 +1098,7 @@ static int get_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, cha
 	char buf[64], *pch, *srcip;
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "";
+		*value = dmstrdup("");
 		return 0;
 	}
 
@@ -1156,7 +1119,7 @@ static int get_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, c
 	char *pch, *srcip;
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "";
+		*value = dmstrdup("");
 		return 0;
 	}
 
@@ -1189,12 +1152,12 @@ static int get_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char
 		dmuci_get_value_by_section_string(p->config_section, "proto", &proto);
 
 		if (DM_STRLEN(proto) == 0 || strchr(proto, ' ')) {
-			*value = "255";
+			*value = dmstrdup("255");
 			return 0;
 		}
 
 		if (*proto == '0' || strcmp(proto, "all") == 0) {
-			*value = "-1";
+			*value = dmstrdup("-1");
 			return 0;
 		}
 	}
@@ -1204,6 +1167,7 @@ static int get_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char
 		return 0;
 	}
 
+	// cppcheck-suppress cert-MSC24-C
 	FILE *fp = fopen("/etc/protocols", "r");
 	if (fp == NULL)
 		return 0;
@@ -1240,7 +1204,7 @@ static int get_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, cha
 		if (tmp)
 			*tmp = '\0';
 		if (*v == '\0') {
-			*value = "-1";
+			*value = dmstrdup("-1");
 			return 0;
 		}
 		*value = v;
@@ -1257,7 +1221,7 @@ static int get_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void
 	char *tmp, *v;
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "-1";
+		*value = dmstrdup("-1");
 		return 0;
 	}
 
@@ -1288,7 +1252,7 @@ static int get_rule_source_port(char *refparam, struct dmctx *ctx, void *data, c
 		if (tmp)
 			*tmp = '\0';
 		if (*v == '\0') {
-			*value = "-1";
+			*value = dmstrdup("-1");
 			return 0;
 		}
 		*value = v;
@@ -1305,7 +1269,7 @@ static int get_rule_source_port_range_max(char *refparam, struct dmctx *ctx, voi
 	char *tmp, *v;
 
 	if (rule_args->is_dynamic_rule) {
-		*value = "-1";
+		*value = dmstrdup("-1");
 		return 0;
 	}
 
@@ -1660,7 +1624,7 @@ static int set_rule_log(char *refparam, struct dmctx *ctx, void *data, char *ins
         return 0;
 }
 
-static int set_rule_interface(struct dmctx *ctx, void *data, char *type, char *value, int action)
+static int set_rule_interface(struct dmctx *ctx, void *data, const char *type, char *value, int action)
 {
 	struct dm_data *p = (struct dm_data *)data;
 	struct rule_sec *rule = (struct rule_sec *)(p->additional_data);
@@ -1965,7 +1929,7 @@ static int set_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, cha
 				break;
 
 			if (*value == '-')
-				value = "";
+				value = dmstrdup("");
 			dmuci_get_value_by_section_string(p->config_section, "dest_port", &v);
 			tmp = DM_STRCHR(v, ':');
 			if (tmp == NULL)
@@ -2030,7 +1994,7 @@ static int set_rule_source_port(char *refparam, struct dmctx *ctx, void *data, c
 				break;
 
 			if (*value == '-')
-				value = "";
+				value = dmstrdup("");
 			dmuci_get_value_by_section_string(p->config_section, "src_port", &v);
 			tmp = DM_STRCHR(v, ':');
 			if (tmp == NULL)
@@ -2130,7 +2094,7 @@ static int get_FirewallDMZ_Status(char *refparam, struct dmctx *ctx, void *data,
 	dmuci_get_value_by_section_string(dmz_args->config_section, "interface", &interface);
 	dmuci_get_value_by_section_string(dmz_args->config_section, "dest_ip", &destip);
 	if (DM_STRLEN(destip) == 0 || DM_STRLEN(interface) == 0) {
-		*value = "Error_Misconfigured";
+		*value = dmstrdup("Error_Misconfigured");
 		return 0;
 	}
 
@@ -2373,11 +2337,11 @@ static int get_service_ipver(char *refparam, struct dmctx *ctx, void *data, char
 
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "family", &ipversion);
 	if (strcasecmp(ipversion, "ipv4") == 0) {
-		*value = "4";
+		*value = dmstrdup("4");
 	} else if (strcasecmp(ipversion, "ipv6") == 0) {
-		*value = "6";
+		*value = dmstrdup("6");
 	} else {
-		*value = "-1";
+		*value = dmstrdup("-1");
 	}
 
 	return 0;
@@ -2509,14 +2473,14 @@ static int get_service_status(char *refparam, struct dmctx *ctx, void *data, cha
 	get_service_enable(refparam, ctx, data, instance, &enable);
 
 	if (DM_STRCMP(enable, "1") != 0) {
-		*value = "Disabled";
+		*value = dmstrdup("Disabled");
 		return 0;
 	}
 
 	get_service_intf(refparam, ctx, data, instance, &intf);
 
 	if (DM_STRLEN(intf) == 0) {
-		*value = "Error_Misconfigured";
+		*value = dmstrdup("Error_Misconfigured");
 		return 0;
 	}
 
diff --git a/src/nat.c b/src/nat.c
index d68e8fe5224275b94da59174a6b08ecc256eb7e8..647704e95f4dfb9cb655e2e6ce8a961f40614d32 100644
--- a/src/nat.c
+++ b/src/nat.c
@@ -98,24 +98,8 @@ static int add_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *dat
 
 static int delete_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *s = NULL, *stmp = NULL;
-
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			uci_foreach_sections_safe("firewall", "zone", stmp, s) {
-				struct uci_section *dmmap_firewall = NULL;
-
-				get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name(s), &dmmap_firewall);
-				dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
-
-				dmuci_delete_by_section(s, NULL, NULL);
-			}
-			break;
-	}
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -141,24 +125,8 @@ static int add_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, ch
 
 static int delete_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *s = NULL, *stmp = NULL;
-
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			uci_foreach_sections_safe("firewall", "redirect", stmp, s) {
-				struct uci_section *dmmap_firewall = NULL;
-
-				get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(s), &dmmap_firewall);
-				dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
-
-				dmuci_delete_by_section(s, NULL, NULL);
-			}
-			return 0;
-	}
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -435,7 +403,7 @@ static int get_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx
 	if (expiry_date && *expiry_date != '\0' && DM_STRTOL(expiry_date) > 0) {
 		dmasprintf(value, "%lld", (long long)(DM_STRTOL(expiry_date) - time(NULL)));
 	} else {
-		*value = "0";
+		*value = dmstrdup("0");
 	}
 	return 0;
 }
@@ -487,7 +455,7 @@ static int get_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx,
 	char *src_dport = NULL;
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "src_dport", &src_dport);
 	if (src_dport && *src_dport == '\0') {
-		*value = "0";
+		*value = dmstrdup("0");
 		return 0;
 	}
 
diff --git a/src/nat_porttrigger.c b/src/nat_porttrigger.c
index cd2200b08ae781f29a018e15c9c670b165032680..dd486f8f42ae353cf893c1bd50fe96c993129516 100644
--- a/src/nat_porttrigger.c
+++ b/src/nat_porttrigger.c
@@ -43,28 +43,28 @@ int browseNATPortTriggerInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
 
 static int browseNATPortTriggerRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
 {
-        struct uci_section *p = NULL;
+	struct uci_section *p = NULL;
 	struct dm_data data = {0};
 	char *name = NULL;
 	char *buf = NULL;
-	int parent_inst = 0;
-	parent_inst = atoi(prev_instance);
+	int parent_inst = (int)strtol(prev_instance, NULL, 10);
 
 	uci_foreach_sections("port-trigger", "rule", p) {
 		int inst = 0;
 		int ptg_inst = 0;
-		dmuci_get_section_name(section_name(p),&name);
+		dmuci_get_section_name(section_name(p), &name);
 		if (name) {
-			sscanf(name, "port_trigger_%d_rule_%d",&ptg_inst,&inst);
+			sscanf(name, "port_trigger_%d_rule_%d",&ptg_inst, &inst);
 			if ((inst == 0) || (ptg_inst != parent_inst))
 				continue;
 			dmasprintf(&buf, "%d", inst);
 			data.config_section = p;
+
 			if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&data, buf) == DM_STOP)
 				break;
 		}
 	}
-        return 0;
+	return 0;
 }
 
 /*************************************************************
@@ -89,64 +89,38 @@ int addObjNATPortTrigger(char *refparam, struct dmctx *ctx, void *data, char **i
 int delObjNATPortTrigger(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
 	struct uci_section *s = NULL, *stmp = NULL;
-	char *name;
-
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", &name);
-			uci_foreach_option_eq_safe("port-trigger", "rule", "port_trigger", name, stmp, s) {
-                                dmuci_delete_by_section(s, NULL, NULL);
-                        }
-
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			uci_foreach_sections_safe("port-trigger", "port_trigger", stmp, s) {
-
-				dmuci_delete_by_section(s, NULL, NULL);
-			}
-			uci_foreach_sections_safe("port-trigger", "rule", stmp, s) {
+	char *name = NULL;
 
-				dmuci_delete_by_section(s, NULL, NULL);
-			}
-			break;
+	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", &name);
+	uci_foreach_option_eq_safe("port-trigger", "rule", "port_trigger", name, stmp, s) {
+		dmuci_delete_by_section(s, NULL, NULL);
 	}
+
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
 	return 0;
 }
 
 static int addObjNATPortTriggerRule(char *refparam, struct dmctx *ctx, void *data, char **instance)
 {
-        struct uci_section *port_trigger = ((struct dm_data *)data)->config_section;
-        struct uci_section *s = NULL;
-        char s_name[50] = {0};
+	struct uci_section *port_trigger = ((struct dm_data *)data)->config_section;
+	struct uci_section *s = NULL;
+	char s_name[50] = {0};
 	char *name = NULL;
 
-        snprintf(s_name, sizeof(s_name), "%s_rule_%s", section_name(port_trigger),*instance);
+	snprintf(s_name, sizeof(s_name), "%s_rule_%s", section_name(port_trigger),*instance);
 
 	dmuci_add_section("port-trigger", "rule", &s);
-        dmuci_rename_section_by_section(s, s_name);
+	dmuci_rename_section_by_section(s, s_name);
+
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", &name);
 	dmuci_set_value_by_section(s, "port_trigger", name);
 
-        return 0;
+	return 0;
 }
 
 static int delObjNATPortTriggerRule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *s = NULL, *stmp = NULL;
-	char *name;
-
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", &name);
-                        uci_foreach_option_eq_safe("port-trigger", "rule", "port_trigger", name, stmp, s) {
-                                dmuci_delete_by_section(s, NULL, NULL);
-                        }
-			break;
-	}
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
 	return 0;
 }