diff --git a/src/attrs.c b/src/attrs.c
index ebcd76d709e6335fe58170eaef5b50d6c0d2f041..30011a00fb32006a452cde6634f14d92423f0f92 100644
--- a/src/attrs.c
+++ b/src/attrs.c
@@ -1,6 +1,7 @@
 #include "attrs.h"
-#include "settings.h"
+#include <string.h>
 #include <utils/strings.h>
+#include "settings.h"
 
 void newattrs(log_gattrrec **gattr, short numattrs, log_kattrrec *kattr)
 {
diff --git a/src/gate.c b/src/gate.c
index 940afb5653a45afcbde27b7b266b1cf1f2f68f99..d06e7d4dd2f8c240adce7e9603b4e339b230d72e 100644
--- a/src/gate.c
+++ b/src/gate.c
@@ -271,8 +271,11 @@ void closergate(short x, short y)
 	log_page *current_page = get_current_page();
 
 	if (gg.textinvisible)
+	{
 		gg.nearlabel = NULL;
-	else {
+	}
+	else
+	{
 		gg.nearlabel = current_page->lbase;
 		while (gg.nearlabel != NULL &&
 				(x < gg.nearlabel->x ||
@@ -282,12 +285,16 @@ void closergate(short x, short y)
 			gg.nearlabel = gg.nearlabel->next;
 		}
 	}
-	if (gg.nearlabel != NULL) {
+	
+	if (gg.nearlabel != NULL)
+	{
 		gg.nearbox = NULL;
 		gg.neargate = NULL;
 		return;
 	}
-	if (!gg.textinvisible) {
+	
+	if (!gg.textinvisible)
+	{
 		gg.nearbox = current_page->bbase;
 		while (gg.nearbox != NULL &&
 				((x != gg.nearbox->x1 && x != gg.nearbox->x2 &&
@@ -295,13 +302,18 @@ void closergate(short x, short y)
 				  y != gg.nearbox->y2) || x < gg.nearbox->x1 ||
 				 x > gg.nearbox->x2 || y < gg.nearbox->y1 || y > gg.nearbox->y2))
 			gg.nearbox = gg.nearbox->next;
-	} else
+	}
+	else
+	{
 		gg.nearbox = NULL;
+	}
+
 	if (gg.nearbox != NULL)
 	{
 		gg.neargate = NULL;
 		return;
 	}
+	
 	gg.neargate = current_page->gbase;
 	while (gg.neargate != NULL && !insidegate(gg.neargate, x, y))
 		gg.neargate = gg.neargate->next;
@@ -463,7 +475,8 @@ void disconnectgate(log_grec *gate)
 		if (!P_inset(i, done))
 		{
 			j = i;
-			do {
+			do
+			{
 				chggatepin(gate, j, &oldnode[i - 1]);
 				P_addset(done, j);
 				j = gate->kind->pin[j - 1].c;
@@ -601,11 +614,14 @@ int connectgate(log_grec *gate)
 			}
 			g1 = g1->next;
 		}
+
 		if (n1 != NULL)
 			queuecombine(&cnbase, &gate->pin[ptrs[i] - 1], n1);
 	}
+	
 	if (gate->kind->simtype == simtype_common && gate->sig != 0)
 		queuecombine(&cnbase, &gg.signaltab[gate->sig - 1].np, gate->pin);
+
 	gg.actflag = true;
 	calltoolgate(gate, act_connectgate);
 	success = gg.actflag;
@@ -682,11 +698,13 @@ void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs)
 	clipon();
 	drawgatex(g);
 	clipoff();
+
 	if (!connectgate(g))
 	{
 		frygate(g);
 		disposegate(&g);
 	}
+	
 	gg.refrflag = true;
 	gg.neargate = g;
 }
diff --git a/src/node.c b/src/node.c
index 8992fe08f618ee2547a95c91b87f2eaa7a039d59..c677b798ed63ff28c9cd35511c6e9d0e9032e1f2 100644
--- a/src/node.c
+++ b/src/node.c
@@ -75,6 +75,7 @@ void disposenode(log_nrec **node)
 	trace_message("Dispose node %p\n", *node);
 	if (*node == NULL)
 		return;
+
 	if ((*node)->conflict || (*node)->oconflict)
 	{
 		n1 = nodeconflictbase;
@@ -91,8 +92,10 @@ void disposenode(log_nrec **node)
 		else
 			n2->confnext = (*node)->confnext;
 	}
+
 	if (*node == gg.probenode)
 		gg.probenode = NULL;
+	
 	stamp(&(*node)->simtype->netstamp);
 	calltoolnode(*node, act_disposenode);
 	n1 = gg.nbase;
@@ -104,6 +107,7 @@ void disposenode(log_nrec **node)
 	{
 		while (n1 != NULL && n1->next != *node)
 			n1 = n1->next;
+		
 		if (n1 == NULL)
 			report(10, rtn);
 		else
@@ -151,13 +155,19 @@ void unrefnode(log_nrec **node)
 {
 	if (*node == NULL)
 		return;
+
 	(*node)->ref--;
 	trace_message("Unref node %p -> %d\n", *node, (*node)->ref);
+	
 	if ((*node)->ref > 0)
 		return;
+	
 	if ((*node)->ref < 0)
+	{
 		report(10, rtn);
-	else {
+	}
+	else
+	{
 		if (!(*node)->keep)
 			disposenode(node);
 	}