diff --git a/include/page.h b/include/page.h
index 102cc17d7400967139d53ed5c33700240cb801fc..7401611a41f24676ee7ebbb1f563dfcc67284391 100644
--- a/include/page.h
+++ b/include/page.h
@@ -28,7 +28,7 @@ typedef struct log_page {
 
 void chpage(log_page *page);
 
-void chpageplace(short pg, short x1, short y1, short x2, short y2);
+void chpageplace(log_page *page, short x1, short y1, short x2, short y2);
 
 int pageempty(short pg);
 
diff --git a/src/gate.c b/src/gate.c
index cd632f4313994919388de8fd8e38243cca37553e..71efb9aef3f91c89ffadb249e4377c6a7376b4e9 100644
--- a/src/gate.c
+++ b/src/gate.c
@@ -123,7 +123,7 @@ void linkgate(log_grec **gate)
 {
 	(*gate)->next = gg.pages[gg.curpage - 1]->gbase;
 	gg.pages[gg.curpage - 1]->gbase = *gate;
-	chpageplace((int)gg.curpage, (*gate)->x - (*gate)->kind->bbmax,
+	chpageplace(gg.pages[gg.curpage - 1], (*gate)->x - (*gate)->kind->bbmax,
 			(*gate)->y - (*gate)->kind->bbmax, (*gate)->x + (*gate)->kind->bbmax,
 			(*gate)->y + (*gate)->kind->bbmax);
 }
@@ -247,7 +247,7 @@ void unlkgate(log_grec **gate)
 		gg.pages[gg.curpage - 1]->gbase = (*gate)->next;
 	else
 		g1->next = (*gate)->next;
-	chpageplace((int)gg.curpage, (*gate)->x - (*gate)->kind->bbmax,
+	chpageplace(gg.pages[gg.curpage - 1], (*gate)->x - (*gate)->kind->bbmax,
 			(*gate)->y - (*gate)->kind->bbmax, (*gate)->x + (*gate)->kind->bbmax,
 			(*gate)->y + (*gate)->kind->bbmax);
 }
diff --git a/src/label.c b/src/label.c
index 64fa9452b10979f624248309a30fadc57ed13558..d24422da12588a30abc47bd9e049be2219712da1 100644
--- a/src/label.c
+++ b/src/label.c
@@ -385,7 +385,7 @@ void unlinklabel(log_lrec *l)
 		gg.pages[gg.curpage - 1]->lbase = l->next;
 	else
 		l1->next = l->next;
-	chpageplace((int)gg.curpage, l->x, l->y, l->x + l->w, l->y + 2);
+	chpageplace(gg.pages[gg.curpage - 1], l->x, l->y, l->x + l->w, l->y + 2);
 	stamp(&gg.labelstamp);
 }
 
diff --git a/src/log.c b/src/log.c
index eb25f11e989c98fa7d4d377cdb9ff0eb25256bd6..fb0310cc51c7c2d01e8b9473bbaa5ed122d5f556 100644
--- a/src/log.c
+++ b/src/log.c
@@ -2170,7 +2170,7 @@ static void unlinkbox(log_brec *b)
 		gg.pages[gg.curpage - 1]->bbase = b->next;
 	else
 		b1->next = b->next;
-	chpageplace((int)gg.curpage, b->x1, b->y1, b->x2, b->y2);
+	chpageplace(gg.pages[gg.curpage - 1], b->x1, b->y1, b->x2, b->y2);
 	stamp(&gg.boxstamp);
 }
 
@@ -4238,7 +4238,7 @@ static void pastebuf(baseptrs *bases, short x, short y)
 					logfont_lfont, l1->name);
 		}
 		clipoff();
-		chpageplace((int)gg.curpage, l1->x, l1->y, l1->x + l1->w, l1->y + 2);
+		chpageplace(gg.pages[gg.curpage - 1], l1->x, l1->y, l1->x + l1->w, l1->y + 2);
 		stamp(&gg.labelstamp);
 		l = l->next;
 	}
@@ -4258,7 +4258,7 @@ static void pastebuf(baseptrs *bases, short x, short y)
 		if (!gg.textinvisible)
 			drawboxc(b1, gg.color.dashbox);
 		clipoff();
-		chpageplace((int)gg.curpage, b1->x1, b1->y1, b1->x2, b1->y2);
+		chpageplace(gg.pages[gg.curpage - 1], b1->x1, b1->y1, b1->x2, b1->y2);
 		stamp(&gg.boxstamp);
 		b = b->next;
 	}
@@ -4566,7 +4566,7 @@ static void moveobject()
 		oldy1 = gg.nearlabel->y;
 		oldx2 = oldx1 + gg.nearlabel->w;
 		oldy2 = oldy1 + 2;
-		chpageplace((int)gg.curpage, oldx1, oldy1, oldx2, oldy2);
+		chpageplace(gg.pages[gg.curpage - 1], oldx1, oldy1, oldx2, oldy2);
 		stamp(&gg.labelstamp);
 		clipon();
 		eralabel(gg.nearlabel);
@@ -4600,7 +4600,7 @@ static void moveobject()
 			}
 		} while (gg.t.depressed);
 		remcursor();
-		chpageplace(oldpg, oldx1, oldy1, oldx2, oldy2);
+		chpageplace(gg.pages[oldpg - 1], oldx1, oldy1, oldx2, oldy2);
 		if (gg.incircuit && !oo && !gg.t.off)
 		{
 			gg.posx += x1;
@@ -4620,7 +4620,7 @@ static void moveobject()
 					gg.posy * gg.scale - gg.yoff + 2, logfont_lfont,
 					gg.nearlabel->name);
 			gg.refrflag = true;
-			chpageplace((int)gg.curpage, gg.nearlabel->x, gg.nearlabel->y,
+			chpageplace(gg.pages[gg.curpage - 1], gg.nearlabel->x, gg.nearlabel->y,
 					gg.nearlabel->x + gg.nearlabel->w, gg.nearlabel->y + 2);
 		}
 		else
@@ -4643,7 +4643,7 @@ static void moveobject()
 		oldy1 = gg.nearbox->y1;
 		oldx2 = gg.nearbox->x2;
 		oldy2 = gg.nearbox->y2;
-		chpageplace((int)gg.curpage, oldx1, oldy1, oldx2, oldy2);
+		chpageplace(gg.pages[gg.curpage - 1], oldx1, oldy1, oldx2, oldy2);
 		stamp(&gg.boxstamp);
 		clipon();
 		drawboxc(gg.nearbox, gg.color.backgr);
@@ -4718,7 +4718,7 @@ static void moveobject()
 		gg.nearbox->x2 = hx2;
 		gg.nearbox->y1 = vy1;
 		gg.nearbox->y2 = vy2;
-		chpageplace(oldpg, oldx1, oldy1, oldx2, oldy2);
+		chpageplace(gg.pages[oldpg - 1], oldx1, oldy1, oldx2, oldy2);
 		if (gg.incircuit && !oo && !gg.t.off)
 		{
 			if (gg.curpage != oldpg)
@@ -4732,7 +4732,7 @@ static void moveobject()
 			clipon();
 			drawboxc(gg.nearbox, gg.color.dashbox);
 			clipoff();
-			chpageplace((int)gg.curpage, gg.nearbox->x1, gg.nearbox->y1,
+			chpageplace(gg.pages[gg.curpage - 1], gg.nearbox->x1, gg.nearbox->y1,
 					gg.nearbox->x2, gg.nearbox->y2);
 			gg.refrflag = true;
 		}
@@ -9173,7 +9173,7 @@ static void touchgate(log_grec *g)
 	calltoolgate(g, act_touchgate);
 
 	if (gg.actflag)
-		chpageplace((int)gg.curpage, g->x - g->kind->bbmax, g->y - g->kind->bbmax,
+		chpageplace(gg.pages[gg.curpage - 1], g->x - g->kind->bbmax, g->y - g->kind->bbmax,
 				g->x + g->kind->bbmax, g->y + g->kind->bbmax);
 	else if (!gg.invisible || g->kind->flag.U3.visible)
 		flipgate(g);
@@ -9395,7 +9395,7 @@ void addlabelat(short x, short y, char *s)
 	l->x = x;
 	l->y = y;
 	l->w = m_strwidth(logfont_lfont, s) / log_scale0;
-	chpageplace((int)gg.curpage, x, y, x + l->w, y + 2);
+	chpageplace(gg.pages[gg.curpage - 1], x, y, x + l->w, y + 2);
 	remcursor();
 	clipon();
 	m_color((long)gg.color.labeltext);
@@ -9623,7 +9623,7 @@ static void editlabel(log_lrec *l)
 		strcpy(l->name, name);
 		l->w = m_strwidth(logfont_lfont, l->name) / log_scale0;
 		stamp(&gg.labelstamp);
-		chpageplace((int)gg.curpage, l->x, l->y, l->x + l->w, l->y + 2);
+		chpageplace(gg.pages[gg.curpage - 1], l->x, l->y, l->x + l->w, l->y + 2);
 	}
 	labelcaps = nk_setcapslock(savecaps);
 	gg.t.depressed = false;
@@ -9654,7 +9654,7 @@ void addboxat(short x1, short y1, short x2, short y2)
 	clipon();
 	drawboxc(b, gg.color.dashbox);
 	clipoff();
-	chpageplace((int)gg.curpage, x1, y1, x2, y2);
+	chpageplace(gg.pages[gg.curpage - 1], x1, y1, x2, y2);
 	gg.nearbox = b;
 }
 
diff --git a/src/page.c b/src/page.c
index 576bd018a1dc6a81951254f8c3088335c29fed66..c43ac28ccd052b99f481182da02864393f9024eb 100644
--- a/src/page.c
+++ b/src/page.c
@@ -22,13 +22,13 @@ void chpage(log_page *page)
 }
 
 
-void chpageplace(short pg, short x1, short y1, short x2, short y2)
+void chpageplace(log_page *page, short x1, short y1, short x2, short y2)
 {
 	log_regrec *r;
 
-	stamp(&gg.pages[pg - 1]->pagestamp);
-	gg.pages[pg - 1]->pagechanged = true;
-	r = gg.pages[pg - 1]->pageregions;
+	stamp(&page->pagestamp);
+	page->pagechanged = true;
+	r = page->pageregions;
 	if (r == NULL)
 		return;
 	sortshints(&x1, &x2);
diff --git a/src/wire.c b/src/wire.c
index 71d8c8fe658bc0260b15ad028a2e0a30dd11e6ca..ef4408ec938e4d4f973a311711c90fa16f3ef915 100644
--- a/src/wire.c
+++ b/src/wire.c
@@ -88,7 +88,7 @@ void disphw(log_hwrec **hw)
 		else
 			hw1->next = (*hw)->next;
 	}
-	chpageplace((int)gg.curpage, (*hw)->x1, (*hw)->y, (*hw)->x2, (*hw)->y);
+	chpageplace(gg.pages[gg.curpage - 1], (*hw)->x1, (*hw)->y, (*hw)->x2, (*hw)->y);
 	Free(*hw);
 }
 
@@ -141,7 +141,7 @@ void dispvw(log_vwrec **vw)
 		else
 			vw1->next = (*vw)->next;
 	}
-	chpageplace((int)gg.curpage, (*vw)->x, (*vw)->y1, (*vw)->x, (*vw)->y2);
+	chpageplace(gg.pages[gg.curpage - 1], (*vw)->x, (*vw)->y1, (*vw)->x, (*vw)->y2);
 	Free(*vw);
 }
 
@@ -197,7 +197,7 @@ void dispsolder(log_srec **s)
 		else
 			s1->next = (*s)->next;
 	}
-	chpageplace((int)gg.curpage, (*s)->x, (*s)->y, (*s)->x, (*s)->y);
+	chpageplace(gg.pages[gg.curpage - 1], (*s)->x, (*s)->y, (*s)->x, (*s)->y);
 	Free(*s);
 }
 
@@ -251,7 +251,7 @@ void addsolder(short x, short y, log_hwrec *hw, log_hwrec *hw2, log_vwrec *vw, l
 		newsolder(&s);
 		s->x = x;
 		s->y = y;
-		chpageplace((int)gg.curpage, x, y, x, y);
+		chpageplace(gg.pages[gg.curpage - 1], x, y, x, y);
 		s->hwire = NULL;
 		s->hwire2 = NULL;
 		s->vwire = NULL;
@@ -763,7 +763,7 @@ void addhwire(short x1, short x2, short y, short colr)
 	hw->x2 = x2;
 	hw->y = y;
 	hw->wcolr = colr;
-	chpageplace((int)gg.curpage, x1, y, x2, y);
+	chpageplace(gg.pages[gg.curpage - 1], x1, y, x2, y);
 	g = gg.pages[gg.curpage - 1]->gbase;
 	while (g != NULL)
 	{
@@ -906,7 +906,7 @@ void addvwire(short x, short y1, short y2, short colr)
 	vw->y2 = y2;
 	vw->x = x;
 	vw->wcolr = colr;
-	chpageplace((int)gg.curpage, x, y1, x, y2);
+	chpageplace(gg.pages[gg.curpage - 1], x, y1, x, y2);
 	g = gg.pages[gg.curpage - 1]->gbase;
 	while (g != NULL)
 	{