diff --git a/src/ai.c b/src/ai.c
index c9be95d..13fb375 100644
--- a/src/ai.c
+++ b/src/ai.c
@@ -269,6 +269,7 @@ static void ai_setMemory(void) {
   lua_pushnumber(L, cur_pilot->id);
   lua_gettable(L, -2);
   lua_setglobal(L, "mem");
+  lua_pop(L, 1);
 }
 
 /**
@@ -338,6 +339,7 @@ int ai_pinit(Pilot* p, char* ai) {
   lua_pushnumber(L, p->id);
   lua_newtable(L);
   lua_settable(L, -3);
+  lua_pop(L, 1);
 
   /* Create the pilot. */
   ai_create(p, (n != 0) ? param : NULL);
@@ -359,6 +361,7 @@ void ai_destroy(Pilot* p) {
   lua_pushnumber(L, p->id);
   lua_pushnil(L);
   lua_settable(L, -3);
+  lua_pop(L, 1);
 
   /* Clean up tasks. */
   if(p->task)
@@ -508,6 +511,7 @@ void ai_think(Pilot* pilot) {
     ai_run(L, "control"); /* Run control. */
     lua_getglobal(L, "control_rate");
     cur_pilot->tcontrol = lua_tonumber(L, -1);
+    lua_pop(L, 1);
   }
   if(cur_pilot->task)
     /* Pilot has a currently running task. */
diff --git a/src/conf.c b/src/conf.c
index d940362..6a97a14 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -20,16 +20,16 @@
 #define conf_loadInt(n,i) \
   lua_getglobal(L,n); \
   if(lua_isnumber(L, -1)) { \
-  i = (int)lua_tonumber(L, -1); \
+    i = (int)lua_tonumber(L, -1); \
   } \
-  lua_remove(L, -1); \
+  lua_pop(L, 1); \
 
 #define conf_loadFloat(n,f) \
   lua_getglobal(L,n); \
   if(lua_isnumber(L, -1)) { \
   f = (double)lua_tonumber(L, -1); \
   } \
-  lua_remove(L,-1);\
+  lua_pop(L,1);\
 
 #define conf_loadBool(n,b) \
   lua_getglobal(L,n); \
@@ -39,14 +39,14 @@
   } \
   else if(lua_isboolean(L, -1)) \
     b = lua_toboolean(L, -1); \
-  lua_remove(L, -1); \
+  lua_pop(L, 1); \
 
 #define conf_loadString(n,s) \
   lua_getglobal(L,n); \
   if(lua_isstring(L, -1)) { \
   s = strdup((char*)lua_tostring(L, -1)); \
   } \
-  lua_remove(L, -1); \
+  lua_pop(L, 1); \
 
 /* Some crap from main. */
 extern int nosound;
@@ -119,7 +119,7 @@ int conf_loadConfig(const char* file) {
     lua_getglobal(L, "data");
     if(lua_isstring(L, -1))
       ldata_setPath((char*)lua_tostring(L, -1));
-    lua_remove(L, -1);
+    lua_pop(L, 1);
 
     /* OpenGL properties.. */
 
@@ -193,8 +193,7 @@ int conf_loadConfig(const char* file) {
       indjoystick = (int)lua_tonumber(L, -1);
     else if(lua_isstring(L, -1))
       namjoystick = strdup((char*)lua_tostring(L, -1));
-
-    lua_remove(L, -1);
+    lua_pop(L, 1);
 
     /* Keybindings. */
     for(i = 0; strcmp(keybindNames[i], "end"); i++) {
@@ -213,7 +212,7 @@ int conf_loadConfig(const char* file) {
           WARN("Found keybind with invalid type field!");
           str = "null";
         }
-        lua_remove(L, -1);
+        lua_pop(L, 1);
 
         /* Get the key. */
         lua_pushstring(L, "key");
@@ -229,7 +228,7 @@ int conf_loadConfig(const char* file) {
           WARN("Found keybind with invalid key field!");
           key = SDLK_UNKNOWN;
         }
-        lua_remove(L, -1);
+        lua_pop(L, 1);
 
         /* Is it reversed? Only used for axis. */
         lua_pushstring(L, "reverse");
@@ -240,7 +239,7 @@ int conf_loadConfig(const char* file) {
           reverse = lua_toboolean(L, -1);
         else
           reverse = 0;
-        lua_remove(L, -1);
+        lua_pop(L, 1);
 
         /* Get the modifier. */
         lua_pushstring(L, "mod");
@@ -249,7 +248,7 @@ int conf_loadConfig(const char* file) {
           mod = (char*)lua_tostring(L, -1);
         else
           mod = NULL;
-        lua_remove(L, -1);
+        lua_pop(L, 1);
 
         if(str != NULL) {
           /* Then the keybind is valid. Get the type. */
@@ -285,10 +284,9 @@ int conf_loadConfig(const char* file) {
         } else {
           WARN("Malformed keybind for %s in '%s'", keybindNames[i], file);
         }
-
-        /* Clean up after table crap. */
-        lua_remove(L,-1);
       }
+      /* Clean up after table crap. */
+      lua_pop(L,1);
     }
   } else {
     /* Failed to load the config file.. */