diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
index 0fbff10..ded9485 100755
--- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
+++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
@@ -71,96 +71,81 @@ if [ -n "$LAN1PORT" ] ; then
     setupPorts "$LAN1PORT" "${LAN1MODE}"
 fi
 
-if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
-
-    SWITCHHW=$(swconfig list | awk '{ print $4 }')
-
-    uci set network.$SWITCHDEV=switch
-    uci set network.$SWITCHDEV.name=$SWITCHHW
-    uci set network.$SWITCHDEV.enable=1
-    uci set network.$SWITCHDEV.reset=1
-    uci set network.$SWITCHDEV.enable_vlan=1
-
-    uci set network.${SWITCHDEV}_1=switch_vlan
-    uci set network.${SWITCHDEV}_1.device=$SWITCHHW
-    uci set network.${SWITCHDEV}_1.vlan=1
-    uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
-
-    echo "# Allow IPv6 RAs on WAN Port" >> /etc/sysctl.conf
-
-    if [[ "$WANDEV" = "$SWITCHDEV" ]] || ! [[ -z "$WAN_PORTS" ]]; then
-        uci set network.${SWITCHDEV}_2=switch_vlan
-        uci set network.${SWITCHDEV}_2.device=$SWITCHHW
-        uci set network.${SWITCHDEV}_2.vlan=2
-        uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
-
-        echo "net.ipv6.conf.$WANDEV.2.accept_ra_defrtr = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.2.accept_ra_pinfo = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.2.autoconf = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.2.accept_ra_rtr_pref = 1" >> /etc/sysctl.conf
-    else
-        echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.autoconf = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 1" >> /etc/sysctl.conf
-    fi
-    
-    uci set network.${SWITCHDEV}_3=switch_vlan
-    uci set network.${SWITCHDEV}_3.device=$SWITCHHW
-    uci set network.${SWITCHDEV}_3.vlan=3
-    uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
-
-    uci set network.mesh.ifname="$SWITCHDEV.1 bat0"
-
-    uci set network.ethmesh.ifname="$SWITCHDEV.3"
-
-    if [[ "$WANDEV" = "$SWITCHDEV" ]]; then
-        uci set network.wan.ifname=$WANDEV.2
-    else
-        uci set network.wan.ifname=$WANDEV
-    fi
-
-    uci commit network
+if [ "$ONE_PORT" = "YES" ] ; then
+	if ! uci -q get "network.$SWITCHDEV.ifname" || [ "$FORCEPARSE" = '1' ] ; then
+		uci set "network.$SWITCHDEV=interface"
+		uci set "network.$SWITCHDEV.ifname=$SWITCHDEV"
+		wanon="0"
+		if [ "$ETHMODE" = "WAN" ]; then
+			wanon="1"
+			uci set network.mesh.ifname="bat0"
+			uci set network.wan.ifname="$WANDEV"
+			uci del network.ethmesh.ifname
+			uci del network.eth0.macaddr
+		elif [ "$ETHMODE" = "CLIENT" ] ; then
+			uci set network.mesh.ifname="bat0 $SWITCHDEV"
+			uci set network.wan.ifname="eth1" #eth1 because it is default in config file
+			uci del network.ethmesh.ifname
+			uci del network.eth0.macaddr
+		else # default=BATMAN
+			uci set network.mesh.ifname="bat0"
+			uci set network.wan.ifname="eth1" #eth1 because it is default in config file
+			uci set network.ethmesh.ifname="$SWITCHDEV"
+			ETHMESHMAC="$(macFlipLocalBit "$ROUTERMAC")"
+			ETHMESHDEV="$SWITCHDEV"
+		fi
+		uci -q commit network
+	fi
+else
+	if ! uci -q get "network.$SWITCHDEV" > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
+		SWITCHHW="$(swconfig list | awk '{ print $4 }')"
+
+		uci set "network.$SWITCHDEV=switch"
+		uci set "network.$SWITCHDEV.name=$SWITCHHW"
+		uci set "network.$SWITCHDEV.enable=1"
+		uci set "network.$SWITCHDEV.reset=1"
+		uci set "network.$SWITCHDEV.enable_vlan=1"
+
+		uci set "network.${SWITCHDEV}_1=switch_vlan"
+		uci set "network.${SWITCHDEV}_1.device=$SWITCHHW"
+		uci set "network.${SWITCHDEV}_1.vlan=1"
+		uci set "network.${SWITCHDEV}_1.ports=$CLIENT_PORTS"
+
+		echo "# Allow IPv6 RAs on WAN Port" >> /etc/sysctl.conf
+
+		wanon="1"
+		if [ "$WANDEV" = "$SWITCHDEV" ] || [ -n "$WAN_PORTS" ]; then
+			WANDEV="${SWITCHDEV}.2"
+			uci set "network.${SWITCHDEV}_2=switch_vlan"
+			uci set "network.${SWITCHDEV}_2.device=$SWITCHHW"
+			uci set "network.${SWITCHDEV}_2.vlan=2"
+			uci set "network.${SWITCHDEV}_2.ports=$WAN_PORTS"
+		fi
+		
+		ETHMESHDEV="$SWITCHDEV.3"
+		uci set "network.${SWITCHDEV}_3=switch_vlan"
+		uci set "network.${SWITCHDEV}_3.device=$SWITCHHW"
+		uci set "network.${SWITCHDEV}_3.vlan=3"
+		uci set "network.${SWITCHDEV}_3.ports=$BATMAN_PORTS"
+		
+		uci set network.mesh.ifname="$SWITCHDEV.1 bat0"
+		uci set network.wan.ifname="$WANDEV"
+		uci set network.ethmesh.ifname="$ETHMESHDEV"
+		
+		uci -q commit network
+	fi
 fi
-
-if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [ "$FORCEPARSE" = '1' ] ) ; then
-    uci set network.$SWITCHDEV=interface
-    uci set network.$SWITCHDEV.ifname=$SWITCHDEV
-    if [ "$ETHMODE" = "WAN" ]; then
-        echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.autoconf = 1" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 1" >> /etc/sysctl.conf
-        uci set network.mesh.ifname="bat0"
-        uci set network.wan.ifname="$WANDEV"
-        uci del uci set network.ethmesh.ifname
-        uci del network.eth0.macaddr
-    elif [ "$ETHMODE" = "CLIENT" ] ; then
-        echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 0" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 0" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.autoconf = 0" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 0" >> /etc/sysctl.conf
-        uci set network.mesh.ifname="bat0 $SWITCHDEV"
-        uci set network.wan.ifname="eth1" #eth1 because it is default in config file
-        uci del network.ethmesh.ifname
-        uci del network.eth0.macaddr
-    elif [ "$ETHMODE" = "BATMAN" ] ; then
-        echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 0" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 0" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.autoconf = 0" >> /etc/sysctl.conf
-        echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 0" >> /etc/sysctl.conf
-        uci set network.mesh.ifname="bat0"
-        uci set network.wan.ifname="eth1" #eth1 because it is default in config file
-        uci set network.ethmesh.ifname="$SWITCHDEV"
-        fixMac "$(macFlipLocalBit "$ROUTERMAC")" "eth0" "eth0" "1"
-    fi
-    uci commit network
+if [ -n "$wanon" ]; then
+	echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = $wanon" >> /etc/sysctl.conf
+	echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = $wanon" >> /etc/sysctl.conf
+	echo "net.ipv6.conf.$WANDEV.autoconf = $wanon" >> /etc/sysctl.conf
+	echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = $wanon" >> /etc/sysctl.conf
 fi
 
 /etc/init.d/network restart
 
-if [ -n "$ETHMESHMAC" ]; then
-    fixMac "$ETHMESHMAC" "${SWITCHDEV}.3" "ethmesh"
+if [ -n "$ETHMESHMAC" ] && [ -n "$ETHMESHDEV" ]; then
+    fixMac "$ETHMESHMAC" "$ETHMESHDEV" "ethmesh"
 fi
 
 if [ -n "$ROUTERMAC" ]; then
