diff --git a/src/deh_lua.c b/src/deh_lua.c
index 0effe4fa708aeda6f6ffefdf4d2efd845a43f3ea..3176f5d695544cffdf3e11e9bd8db206db026cb7 100644
--- a/src/deh_lua.c
+++ b/src/deh_lua.c
@@ -66,12 +66,12 @@ static inline int lib_freeslot(lua_State *L)
 
 			for (j = SPR_FIRSTFREESLOT; j <= SPR_LASTFREESLOT; j++)
 			{
-				if (used_spr[(j-SPR_FIRSTFREESLOT)/8] & (1<<(j%8)))
+				if (in_bit_array(used_spr, j - SPR_FIRSTFREESLOT))
 					continue; // Already allocated, next.
 				// Found a free slot!
 				CONS_Printf("Sprite SPR_%s allocated.\n",word);
 				strcpy(sprnames[j], word);
-				used_spr[(j-SPR_FIRSTFREESLOT)/8] |= 1<<(j%8); // Okay, this sprite slot has been named now.
+				set_bit_array(used_spr, j - SPR_FIRSTFREESLOT); // Okay, this sprite slot has been named now.
 				// Lua needs to update the value in _G if it exists
 				LUA_UpdateSprName(word, j);
 				lua_pushinteger(L, j);
diff --git a/src/deh_soc.c b/src/deh_soc.c
index fe43cd283483576d3f0fe54b7b9a7923e08d3994..5e068313dd8ae55fc5ee25978a6653f4ffb8eb23 100644
--- a/src/deh_soc.c
+++ b/src/deh_soc.c
@@ -445,11 +445,11 @@ void readfreeslots(MYFILE *f)
 
 				for (i = SPR_FIRSTFREESLOT; i <= SPR_LASTFREESLOT; i++)
 				{
-					if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8)))
+					if (in_bit_array(used_spr, i - SPR_FIRSTFREESLOT))
 						continue; // Already allocated, next.
 					// Found a free slot!
 					strcpy(sprnames[i], word);
-					used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now.
+					set_bit_array(used_spr, i - SPR_FIRSTFREESLOT); // Okay, this sprite slot has been named now.
 					// Lua needs to update the value in _G if it exists
 					LUA_UpdateSprName(word, i);
 					break;
diff --git a/src/deh_tables.c b/src/deh_tables.c
index ed401d68a320188560783872e9c5672d6a41993d..c7c7c604068cd4761ea3944a92cd4efecd9a0ddb 100644
--- a/src/deh_tables.c
+++ b/src/deh_tables.c
@@ -31,7 +31,7 @@
 char *FREE_STATES[NUMSTATEFREESLOTS];
 char *FREE_MOBJS[NUMMOBJFREESLOTS];
 char *FREE_SKINCOLORS[NUMCOLORFREESLOTS];
-UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
+bitarray_t used_spr[BIT_ARRAY_SIZE(NUMSPRITEFREESLOTS)]; // Sprite freeslots in use
 
 const char NIGHTSGRADE_LIST[] = {
 	'F', // GRADE_F
diff --git a/src/deh_tables.h b/src/deh_tables.h
index b71a2a23b98bf84579f6f92d4ab71e93db00526b..b6986adff0166c3132be5f70ca78c7835030998f 100644
--- a/src/deh_tables.h
+++ b/src/deh_tables.h
@@ -23,7 +23,7 @@
 extern char *FREE_STATES[NUMSTATEFREESLOTS];
 extern char *FREE_MOBJS[NUMMOBJFREESLOTS];
 extern char *FREE_SKINCOLORS[NUMCOLORFREESLOTS];
-extern UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
+extern bitarray_t used_spr[BIT_ARRAY_SIZE(NUMSPRITEFREESLOTS)]; // Sprite freeslots in use
 
 #define initfreeslots() {\
 	memset(FREE_STATES, 0, sizeof(FREE_STATES));\