diff --git a/engine/client/m_download.c b/engine/client/m_download.c
index d94962093..f0cca5660 100644
--- a/engine/client/m_download.c
+++ b/engine/client/m_download.c
@@ -5848,7 +5848,6 @@ static void PM_ConfirmSource(void *ctx, promptbutton_t button)
 			Cmd_ExecuteString("menu_download\n", RESTRICT_LOCAL);
 	}
 }
-#endif
 
 //given a url, try to chop it down to just a hostname
 static const char *PrettyHostFromURL(const char *origurl)
@@ -5883,6 +5882,7 @@ static const char *PrettyHostFromURL(const char *origurl)
 
 	return url;
 }
+#endif
 
 qboolean PM_AreSourcesNew(qboolean doprompt)
 {
diff --git a/engine/client/r_surf.c b/engine/client/r_surf.c
index 586fcd47d..03ccaccb4 100644
--- a/engine/client/r_surf.c
+++ b/engine/client/r_surf.c
@@ -3564,7 +3564,9 @@ void Surf_DrawWorld (void)
 	currententity = &r_worldentity;
 
 	{
+#ifdef THREADEDWORLD
 		int sc = r_temporalscenecache.ival;
+#endif
 		RSpeedRemark();
 
 		Surf_LightmapShift(currentmodel);
diff --git a/engine/client/valid.c b/engine/client/valid.c
index 7f8aa6eb6..6de397cd4 100644
--- a/engine/client/valid.c
+++ b/engine/client/valid.c
@@ -542,7 +542,6 @@ qboolean Ruleset_FileLoaded(const char *filename, const qbyte *filedata, size_t
 {	//usually called on worker threads
 	qbyte digest[20];
 	size_t i, j;
-	unsigned int status;
 
 	if (ruleset_current && ruleset_current->filehashes)
 	{
@@ -574,6 +573,7 @@ qboolean Ruleset_FileLoaded(const char *filename, const qbyte *filedata, size_t
 	{
 		if (!strcmp(filename, modifiles[i].name) && (modifiles[i].flags & (cl.teamfortress?FMOD_TF:FMOD_DM)))
 		{
+			unsigned int status;
 			CalcHash(&hash_sha1, digest, sizeof(digest), filedata, filesize);
 
 			for (j = 0; j < modifiles[i].hashes; j++)
@@ -872,6 +872,7 @@ extrafilehash:
 
 	return rs;
 }
+#ifdef HAVE_LEGACY
 static ruleset_t *Ruleset_ParseInternal(const char *name, const char *file)
 {
 	ruleset_t *rs;
@@ -881,6 +882,7 @@ static ruleset_t *Ruleset_ParseInternal(const char *name, const char *file)
 	Z_Free(lazy);
 	return rs;
 }
+#endif
 
 static int QDECL Ruleset_Read(const char *fname, qofs_t size, time_t mtime, void *parm, searchpathfuncs_t *spath)
 {
diff --git a/engine/common/zone.c b/engine/common/zone.c
index 096fbde69..a8088df0f 100644
--- a/engine/common/zone.c
+++ b/engine/common/zone.c
@@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifdef _WIN32
 #include "winquake.h"
 #endif
+#ifdef __GLIBC__
+#include <malloc.h>
+#endif
 
 #define NOZONE
 
@@ -675,6 +678,10 @@ void Cache_Flush(void)
 #ifdef HAVE_CLIENT
 	Image_Purge();
 #endif
+
+#ifdef __GLIBC__
+	malloc_trim(0);
+#endif
 }
 
 static void Hunk_Print_f (void)
diff --git a/engine/gl/gl_font.c b/engine/gl/gl_font.c
index ff91039dd..3e04c9afd 100644
--- a/engine/gl/gl_font.c
+++ b/engine/gl/gl_font.c
@@ -2905,7 +2905,7 @@ void Font_InvalidateColour(vec4_t newcolour)
 	if (font_foretint[0] == newcolour[0] && font_foretint[1] == newcolour[1] && font_foretint[2] == newcolour[2] && font_foretint[3] == newcolour[3])
 		return;
 
-	if (font_colourmask & CON_NONCLEARBG)
+	if ((font_colourmask & CON_NONCLEARBG) && font_foremesh.numindexes)
 	{
 		if (R2D_Flush)
 			R2D_Flush();