--- a/memAlloc.cpp
+++ b/memAlloc.cpp
@@ -31,13 +31,13 @@
 **/
 void memLockHandles(MemType k)
 {
-	for (int i = 0; i <= MEM[k].tos; i++)
+  for (int i = 0; i <= gData->mem[k].tos; i++)
   {
-		if (MEM[k].stack[i].mem)
+    if (gData->mem[k].stack[i].mem)
     {
-			gFr->bufferProcs->lockProc(MEM[k].stack[i].id, true);
+      gFr->bufferProcs->lockProc(gData->mem[k].stack[i].id, true);
     }
-	}
+  }
 }
 
 /**
@@ -47,13 +47,13 @@
 **/
 void memUnlockHandles(MemType k)
 {
-	for (int i = 0; i <= MEM[k].tos; i++)
+  for (int i = 0; i <= gData->mem[k].tos; i++)
   {
-		if (MEM[k].stack[i].mem)
+    if (gData->mem[k].stack[i].mem)
     {
-			gFr->bufferProcs->unlockProc(MEM[k].stack[i].id);
+      gFr->bufferProcs->unlockProc(gData->mem[k].stack[i].id);
     }
-	}
+  }
 }
 
 /**
@@ -63,14 +63,14 @@
 **/
 void memFreeAll(MemType k)
 {
-	for (int i = MEM[k].tos; i >= 0; i--)
+  for (int i = gData->mem[k].tos; i >= 0; i--)
   {
-		if (MEM[k].stack[i].mem)
+    if (gData->mem[k].stack[i].mem)
     {
-			gFr->bufferProcs->freeProc(MEM[k].stack[i].id);
-		}
-	}
-	MEM[k].tos = -1;
+      gFr->bufferProcs->freeProc(gData->mem[k].stack[i].id);
+    }
+  }
+  gData->mem[k].tos = -1;
 }
 
 /**
@@ -81,17 +81,17 @@
 **/
 void memFree(MemType k, void *buf)
 {
-	for (int i = MEM[k].tos; i >= 0; i--)
+  for (int i = gData->mem[k].tos; i >= 0; i--)
   {
     // Found the match
-		if (MEM[k].stack[i].mem == buf)
+    if (gData->mem[k].stack[i].mem == buf)
     {
-			gFr->bufferProcs->unlockProc(MEM[k].stack[i].id);
-			gFr->bufferProcs->freeProc(MEM[k].stack[i].id);
-			MEM[k].stack[i].mem = NULL;
-			return;
-		}
-	}
+      gFr->bufferProcs->unlockProc(gData->mem[k].stack[i].id);
+      gFr->bufferProcs->freeProc(gData->mem[k].stack[i].id);
+      gData->mem[k].stack[i].mem = NULL;
+      return;
+    }
+  }
 }
 
 /**
@@ -101,7 +101,7 @@
 **/
 void memInit(MemType k)
 {
-	MEM[k].tos = -1;
+  gData->mem[k].tos = -1;
 }
 
 /**
@@ -112,33 +112,33 @@
 **/
 void *memAlloc(MemType k, int32 size)
 {
-	if (++MEM[k].tos >= MAX_STACK)
+  if (++gData->mem[k].tos >= MAX_STACK)
   {
-		MEM[k].tos--;
-		*gResult = memFullErr;
-		display("memAlloc(1): out of memory");
-		return NULL;
-	}
+    gData->mem[k].tos--;
+    *gResult = memFullErr;
+    display("memAlloc(1): out of memory");
+    return NULL;
+  }
 
-	BufferProcs *bufferProcs = gFr->bufferProcs;
-	if (bufferProcs->allocateProc(size, &MEM[k].stack[MEM[k].tos].id))
+  BufferProcs *bufferProcs = gFr->bufferProcs;
+  if (bufferProcs->allocateProc(size, &gData->mem[k].stack[gData->mem[k].tos].id))
   {
-    MEM[k].tos--;
-		*gResult = memFullErr;
-		display("memAlloc(2): out of memory");
-		return NULL;
-	}
+    gData->mem[k].tos--;
+    *gResult = memFullErr;
+    display("memAlloc(2): out of memory");
+    return NULL;
+  }
 
-	MEM[k].stack[MEM[k].tos].mem = bufferProcs->lockProc(MEM[k].stack[MEM[k].tos].id, true);
-	if (MEM[k].stack[MEM[k].tos].mem == NULL)
+  gData->mem[k].stack[gData->mem[k].tos].mem = bufferProcs->lockProc(gData->mem[k].stack[gData->mem[k].tos].id, true);
+  if (gData->mem[k].stack[gData->mem[k].tos].mem == NULL)
   {
-    MEM[k].tos--;
-		*gResult = memFullErr;
-		display("memAlloc(3): out of memory");
-		return NULL;
-	}
+    gData->mem[k].tos--;
+    *gResult = memFullErr;
+    display("memAlloc(3): out of memory");
+    return NULL;
+  }
 
-	void *p = (unsigned char *)MEM[k].stack[MEM[k].tos].mem;
+  void *p = (unsigned char *)gData->mem[k].stack[gData->mem[k].tos].mem;
 
-	return p;
+  return p;
 }