diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c
index 12a13aeb954ba40aeb3573a18a9641e0ecd5bfe7..bf77fea4fd4ffe3dfa14aea611383b92ee7d16ec 100644
--- a/src/conio/bitmap_con.c
+++ b/src/conio/bitmap_con.c
@@ -299,7 +299,6 @@ int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy)
 {
 	int	direction=1;
 	int	cy;
-	int	sy;
 	int	destoffset;
 	int	sourcepos;
 	int width=ex-x+1;
diff --git a/src/conio/ciolib.c b/src/conio/ciolib.c
index 21283dd1147b0b2ad0fef7276c66c77c5e589971..2ded0f5e45cb707c4e8736cfae2b4ba7784d1235 100644
--- a/src/conio/ciolib.c
+++ b/src/conio/ciolib.c
@@ -99,8 +99,8 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_textcolor(int colour);
 CIOLIBEXPORT void CIOLIBCALL ciolib_highvideo(void);
 CIOLIBEXPORT void CIOLIBCALL ciolib_lowvideo(void);
 CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void);
-CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e);
-CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e);
+CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,void *e);
+CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,void *e);
 CIOLIBEXPORT void CIOLIBCALL ciolib_textattr(int a);
 CIOLIBEXPORT void CIOLIBCALL ciolib_delay(long a);
 CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a);
@@ -1016,7 +1016,7 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void)
 }
 
 /* **MUST** be implemented */
-CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e)
+CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,void *e)
 {
 	CIOLIB_INIT();
 	
@@ -1024,7 +1024,7 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char
 }
 
 /* **MUST** be implemented */
-CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e)
+CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,void *e)
 {
 	CIOLIB_INIT();
 	
diff --git a/src/conio/ciolib.h b/src/conio/ciolib.h
index 5ef31c7685a0439956e61849c0dfa19930eea2e6..c9100e07671d9a0efce1402dc6c35e13256112ce 100644
--- a/src/conio/ciolib.h
+++ b/src/conio/ciolib.h
@@ -313,8 +313,8 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_textcolor(int colour);
 CIOLIBEXPORT void CIOLIBCALL ciolib_highvideo(void);
 CIOLIBEXPORT void CIOLIBCALL ciolib_lowvideo(void);
 CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void);
-CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e);
-CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e);
+CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,void *e);
+CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,void *e);
 CIOLIBEXPORT void CIOLIBCALL ciolib_textattr(int a);
 CIOLIBEXPORT void CIOLIBCALL ciolib_delay(long a);
 CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a);
diff --git a/src/conio/cterm.c b/src/conio/cterm.c
index 8700cd27dd483d2ab097a787b8a1cefd510efe87..e039fd3f038b77a493861d586a949bba55305e4f 100644
--- a/src/conio/cterm.c
+++ b/src/conio/cterm.c
@@ -2009,34 +2009,34 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
 					cterm->fontbuf[cterm->font_read++]=ch[0];
 					if(cterm->font_read == cterm->font_size) {
 #ifndef CTERM_WITHOUT_CONIO
-						char *buf;
+						char *buf2;
 
-						if((buf=(char *)malloc(cterm->font_size))!=NULL) {
-							memcpy(buf,cterm->fontbuf,cterm->font_size);
+						if((buf2=(char *)malloc(cterm->font_size))!=NULL) {
+							memcpy(buf2,cterm->fontbuf,cterm->font_size);
 							if(cterm->font_slot >= CONIO_FIRST_FREE_FONT) {
 								switch(cterm->font_size) {
 									case 4096:
 										FREE_AND_NULL(conio_fontdata[cterm->font_slot].eight_by_sixteen);
-										conio_fontdata[cterm->font_slot].eight_by_sixteen=buf;
+										conio_fontdata[cterm->font_slot].eight_by_sixteen=buf2;
 										FREE_AND_NULL(conio_fontdata[cterm->font_slot].desc);
 										conio_fontdata[cterm->font_slot].desc=strdup("Remote Defined Font");
 										break;
 									case 3586:
 										FREE_AND_NULL(conio_fontdata[cterm->font_slot].eight_by_fourteen);
-										conio_fontdata[cterm->font_slot].eight_by_fourteen=buf;
+										conio_fontdata[cterm->font_slot].eight_by_fourteen=buf2;
 										FREE_AND_NULL(conio_fontdata[cterm->font_slot].desc);
 										conio_fontdata[cterm->font_slot].desc=strdup("Remote Defined Font");
 										break;
 									case 2048:
 										FREE_AND_NULL(conio_fontdata[cterm->font_slot].eight_by_eight);
-										conio_fontdata[cterm->font_slot].eight_by_eight=buf;
+										conio_fontdata[cterm->font_slot].eight_by_eight=buf2;
 										FREE_AND_NULL(conio_fontdata[cterm->font_slot].desc);
 										conio_fontdata[cterm->font_slot].desc=strdup("Remote Defined Font");
 										break;
 								}
 							}
 							else
-								FREE_AND_NULL(buf);
+								FREE_AND_NULL(buf2);
 						}
 #endif
 						cterm->font_size=0;
diff --git a/src/conio/cterm.h b/src/conio/cterm.h
index fb011f09d6d19389935174f5289c191df77f93e1..0d969bc2f02ccf76fb840940b48c2413a82d4d22 100644
--- a/src/conio/cterm.h
+++ b/src/conio/cterm.h
@@ -81,7 +81,7 @@ struct cterminal {
 	int					height;			// Height of the terminal buffer
 	int					width;			// Width of the terminal buffer
 	int					quiet;			// No sounds are made
-	char				*scrollback;
+	unsigned char				*scrollback;
 	int					backlines;		// Number of lines in scrollback
 	char				DA[1024];		// Device Attributes
 	bool				autowrap;
@@ -125,14 +125,14 @@ struct cterminal {
 	int					font_size;		// Bytes
 	int					doorway_mode;
 	int					doorway_char;	// Indicates next char is a "doorway" mode char
-	int					cursor;			// Current cursor mode (Normal or None)
+	int					cursor;			// Current cursor mode (Normal or None)z
 
 	/* conio function pointers */
 #ifdef CTERM_WITHOUT_CONIO
 	void	(*ciolib_gotoxy)		(struct cterminal *,int,int);
 	int		(*ciolib_wherex)		(struct cterminal *);
 	int		(*ciolib_wherey)		(struct cterminal *);
-	int		(*ciolib_gettext)		(struct cterminal *,int,int,int,int,unsigned char *);
+	int		(*ciolib_gettext)		(struct cterminal *,int,int,int,int,void *);
 	void	(*ciolib_gettextinfo)	(struct cterminal *,struct text_info *);
 	void	(*ciolib_textattr)		(struct cterminal *,int);
 	void	(*ciolib_setcursortype)	(struct cterminal *,int);
@@ -142,7 +142,7 @@ struct cterminal {
 	void	(*ciolib_setvideoflags)	(struct cterminal *,int flags);
 	int		(*ciolib_getvideoflags)	(struct cterminal *);
 	int		(*ciolib_putch)			(struct cterminal *,int);
-	int		(*ciolib_puttext)		(struct cterminal *,int,int,int,int,unsigned char *);
+	int		(*ciolib_puttext)		(struct cterminal *,int,int,int,int,void *);
 	void	(*ciolib_window)		(struct cterminal *,int,int,int,int);
 	int		(*ciolib_cputs)			(struct cterminal *,char *);
 	int		(*ciolib_setfont)		(struct cterminal *,int font, int force, int font_num);
@@ -150,7 +150,7 @@ struct cterminal {
 	void	CIOLIBCALL (*ciolib_gotoxy)		(int,int);
 	int		CIOLIBCALL (*ciolib_wherex)		(void);
 	int		CIOLIBCALL (*ciolib_wherey)		(void);
-	int		CIOLIBCALL (*ciolib_gettext)		(int,int,int,int,unsigned char *);
+	int		CIOLIBCALL (*ciolib_gettext)		(int,int,int,int,void *);
 	void	CIOLIBCALL (*ciolib_gettextinfo)	(struct text_info *);
 	void	CIOLIBCALL (*ciolib_textattr)		(int);
 	void	CIOLIBCALL (*ciolib_setcursortype)	(int);
@@ -160,7 +160,7 @@ struct cterminal {
 	void	CIOLIBCALL (*ciolib_setvideoflags)	(int flags);
 	int		CIOLIBCALL (*ciolib_getvideoflags)	(void);
 	int		CIOLIBCALL (*ciolib_putch)			(int);
-	int		CIOLIBCALL (*ciolib_puttext)		(int,int,int,int,unsigned char *);
+	int		CIOLIBCALL (*ciolib_puttext)		(int,int,int,int,void *);
 	void	CIOLIBCALL (*ciolib_window)		(int,int,int,int);
 	int		CIOLIBCALL (*ciolib_cputs)			(char *);
 	int		CIOLIBCALL (*ciolib_setfont)		(int font, int force, int font_num);
diff --git a/src/conio/x_events.c b/src/conio/x_events.c
index c24e58711dd22409b4d5f78cfef9e922bc9fe120..3a96e935b51ef090ad31c7b4ad0d8f4704b98a36 100644
--- a/src/conio/x_events.c
+++ b/src/conio/x_events.c
@@ -410,7 +410,6 @@ static void handle_resize_event(int width, int height)
 {
 	int newFSH=1;
 	int newFSW=1;
-	int oldscaling=vstat.scaling;
 
 	// No change
 	if((width == vstat.charwidth * vstat.cols * vstat.scaling)
diff --git a/src/sbbs3/addfiles.c b/src/sbbs3/addfiles.c
index 99d8b4a49460a36864a3f2bb45d4c9925ffb5e0e..67297f3cf30b85e3f5273f8890135a3e1e294aea 100644
--- a/src/sbbs3/addfiles.c
+++ b/src/sbbs3/addfiles.c
@@ -80,7 +80,7 @@ int lprintf(int level, const char *fmat, ...)
 	return(chcount);
 }
 
-void prep_desc(uchar *str)
+void prep_desc(char *str)
 {
 	char tmp[1024];
 	int i,j;
@@ -88,11 +88,11 @@ void prep_desc(uchar *str)
 	for(i=j=0;str[i] && j < sizeof(tmp)-1;i++) {
 		if(j && str[i]==' ' && tmp[j-1]==' ' && (mode&KEEP_SPACE))
 			tmp[j++]=str[i];
-		else if(j && str[i]<=' ' && tmp[j-1]==' ')
+		else if(j && str[i]<=' ' && str[i] > 0&& tmp[j-1]==' ')
 			continue;
-		else if(i && !isalnum(str[i]) && str[i]==str[i-1])
+		else if(i && !isalnum((uchar)str[i]) && str[i]==str[i-1])
 			continue;
-		else if(str[i]>=' ')
+		else if(str[i]>=' ' || str[i]<0)
 			tmp[j++]=str[i];
 		else if(str[i]==TAB || (str[i]==CR && str[i+1]==LF))
 			tmp[j++]=' ';
@@ -212,7 +212,7 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
 	char filepath[MAX_PATH+1];
 	char curline[256],nextline[256];
 	char *p;
-	uchar ext[1024],tmpext[513];
+	char ext[1024],tmpext[513];
 	int i,file;
 	long l;
 	BOOL exist;
@@ -282,7 +282,7 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
 						memset(ext,0,513);
 						read(file,ext,512);
 						for(i=512;i;i--)
-							if(ext[i-1]>' ')
+							if(ext[i-1]>' ' || ext[i-1]<0)
 								break;
 						ext[i]=0;
 						if(mode&ASCII_ONLY)
@@ -291,10 +291,10 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
 							sprintf(tmpext,"%.256s",ext);
 							prep_desc(tmpext);
 							for(i=0;tmpext[i];i++)
-								if(isalpha(tmpext[i]))
+								if(isalpha((uchar)tmpext[i]))
 									break;
 							sprintf(f.desc,"%.*s",LEN_FDESC,tmpext+i);
-							for(i=0;f.desc[i]>=' ' && i<LEN_FDESC;i++)
+							for(i=0;(f.desc[i]>=' ' || f.desc[i]<0) && i<LEN_FDESC;i++)
 								;
 							f.desc[i]=0; }
 						close(file);
@@ -428,7 +428,7 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
 			if(nextline[0]==' ') {
 				strcpy(str,nextline);				   /* tack on to end of desc */
 				p=str+dskip;
-				while(*p && *p<=' ') p++;
+				while(*p>0 && *p<=' ') p++;
 				i=LEN_FDESC-strlen(f.desc);
 				if(i>1) {
 					p[i-1]=0;
@@ -485,7 +485,7 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
 					memset(ext,0,513);
 					read(file,ext,512);
 					for(i=512;i;i--)
-						if(ext[i-1]>' ')
+						if(ext[i-1]>' ' || ext[i-1]<0)
 							break;
 					ext[i]=0;
 					if(mode&ASCII_ONLY)
@@ -494,10 +494,10 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
 						sprintf(tmpext,"%.256s",ext);
 						prep_desc(tmpext);
 						for(i=0;tmpext[i];i++)
-							if(isalpha(tmpext[i]))
+							if(isalpha((uchar)tmpext[i]))
 								break;
 						sprintf(f.desc,"%.*s",LEN_FDESC,tmpext+i);
-						for(i=0;f.desc[i]>=' ' && i<LEN_FDESC;i++)
+						for(i=0;(f.desc[i]>=' ' || f.desc[i]<0) && i<LEN_FDESC;i++)
 							;
 						f.desc[i]=0; 
 					}
@@ -539,11 +539,11 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
 
 void synclist(char *inpath, int dirnum)
 {
-	uchar	str[1024];
+	char	str[1024];
 	char	fname[MAX_PATH+1];
 	char	listpath[MAX_PATH+1];
 	uchar*	ixbbuf;
-	uchar*	p;
+	char*	p;
 	int		i,file,found;
 	long	l,m,length;
 	FILE*	stream;
@@ -668,7 +668,8 @@ int main(int argc, char **argv)
 	char revision[16];
 	char str[MAX_PATH+1];
 	char tmp[MAX_PATH+1];
-	uchar *p,exist,listgiven=0,namegiven=0,ext[513]
+	char *p;
+	char exist,listgiven=0,namegiven=0,ext[513]
 		,auto_name[MAX_PATH+1]="FILES.BBS";
 	int i,j,file;
 	uint desc_offset=0, size_offset=0;
@@ -721,7 +722,7 @@ int main(int argc, char **argv)
 		mode|=AUTO_ADD;
 		i=0; 
 	} else {
-		if(!isalnum(argv[1][0]) && argc==2) {
+		if(!isalnum((uchar)argv[1][0]) && argc==2) {
 			printf(usage);
 			return(1); 
 		}
@@ -814,7 +815,7 @@ int main(int argc, char **argv)
 						return(1); 
 			} 
 		}
-		else if(isdigit(argv[j][0])) {
+		else if(isdigit((uchar)argv[j][0])) {
 			if(desc_offset==0)
 				desc_offset=atoi(argv[j]);
 			else
@@ -824,9 +825,9 @@ int main(int argc, char **argv)
 		else if(argv[j][0]=='+') {      /* filelist - FILES.BBS */
 			listgiven=1;
 			if(argc > j+1
-				&& isdigit(argv[j+1][0])) { /* skip x characters before description */
+				&& isdigit((uchar)argv[j+1][0])) { /* skip x characters before description */
 				if(argc > j+2
-					&& isdigit(argv[j+2][0])) { /* skip x characters before size */
+					&& isdigit((uchar)argv[j+2][0])) { /* skip x characters before size */
 					addlist(argv[j]+1,f,atoi(argv[j+1]),atoi(argv[j+2]));
 					j+=2; 
 				}
@@ -908,7 +909,7 @@ int main(int argc, char **argv)
 						read(file,ext,512);
 						if(!(mode&KEEP_DESC)) {
 							sprintf(f.desc,"%.*s",LEN_FDESC,ext);
-							for(i=0;f.desc[i]>=' ' && i<LEN_FDESC;i++)
+							for(i=0;(f.desc[i]>=' ' || f.desc[i]<0) && i<LEN_FDESC;i++)
 								;
 							f.desc[i]=0; 
 						}
diff --git a/src/sbbs3/baja.c b/src/sbbs3/baja.c
index 47522f786d896ccb17abe9da34640c9f45d8941c..ee9b3b81a0ec279c942c16976d1bce2cf1892cef 100644
--- a/src/sbbs3/baja.c
+++ b/src/sbbs3/baja.c
@@ -151,7 +151,7 @@ int32_t val(char *src, char *p)
 	static int inside;
 	int32_t l;
 
-	if(isdigit(*p) || *p=='-')      /* Dec, Hex, or Oct */
+	if(isdigit((uchar)*p) || *p=='-')      /* Dec, Hex, or Oct */
 		l=strtol(p,&p,0);
 	else if(*p=='\'') {  /* Char */
 		p++;
@@ -219,7 +219,7 @@ int32_t val(char *src, char *p)
 }
 
 
-void writecstr(uchar *p)
+void writecstr(char *p)
 {
 	char str[1024];
 	int j=0,inquotes=0;
@@ -233,11 +233,11 @@ void writecstr(uchar *p)
 			continue; }
 		if(*p=='\\')    { /* escape */
 			p++;
-			if(isdigit(*p)) {
+			if(isdigit((uchar)*p)) {
 				sprintf(tmp,"%.3s",p);
 				str[j]=atoi(tmp); 		/* decimal, NOT octal */
-				if(isdigit(*(++p))) 	/* skip up to 3 digits */
-					if(isdigit(*(++p)))
+				if(isdigit((uchar)*(++p))) 	/* skip up to 3 digits */
+					if(isdigit((uchar)*(++p)))
 						p++;
 				j++;
 				continue; }
@@ -245,7 +245,7 @@ void writecstr(uchar *p)
 				case 'x':
 					tmp[0]=*(p++);
 					tmp[1]=0;
-					if(isxdigit(*p)) {	/* if another hex digit, skip too */
+					if(isxdigit((uchar)*p)) {	/* if another hex digit, skip too */
 						tmp[1]=*(p++);
 						tmp[2]=0; }
 					str[j]=(char)ahtoul(tmp);
@@ -284,7 +284,7 @@ void writecstr(uchar *p)
 	fwrite(str,1,j+1,out);
 }
 
-void writestr(uchar *p)
+void writestr(char *p)
 {
 	char str[1024];
 	int j=0;
@@ -309,12 +309,12 @@ void cvttab(char *str)
 			str[i]=' ';
 }
 
-void newvar(uchar* src, uchar *in)
+void newvar(char* src, char *in)
 {
-	uchar name[128];
+	char name[128];
 	int32_t i,l;
 
-	if(isdigit(*in)) {
+	if(isdigit((uchar)*in)) {
 		printf("!SYNTAX ERROR (illegal variable name):\n");
 		printf(linestr,src,line,(char*)in);
 		bail(1); 
@@ -342,10 +342,10 @@ void newvar(uchar* src, uchar *in)
 	vars++;
 }
 
-void writecrc(uchar *src, uchar *in)
+void writecrc(char *src, char *in)
 {
-	uchar	name[128];
-	uchar*	p;
+	char	name[128];
+	char*	p;
 	int32_t	l;
 	int		i;
 
@@ -375,12 +375,12 @@ void writecrc(uchar *src, uchar *in)
 	fwrite(&l,4,1,out);
 }
 
-int32_t isvar(uchar *arg)
+int32_t isvar(char *arg)
 {
-	uchar name[128],*p;
+	char name[128],*p;
 	int32_t i,l;
 
-	if(!arg || !(*arg) || isdigit(*arg))
+	if(!arg || !(*arg) || isdigit((uchar)*arg))
 		return(0);
 
 	sprintf(name,"%.80s",arg);
@@ -407,9 +407,9 @@ int str_cmp(char *s1, char *s2)
 	return(stricmp(s1,s2));
 }
 
-void expdefs(uchar *line)
+void expdefs(char *line)
 {
-	uchar str[512],*p,*sp,sav[2]={0};
+	char str[512],*p,*sp,sav[2]={0};
 	int i;
 
 	str[0]=0;
@@ -429,7 +429,7 @@ void expdefs(uchar *line)
 			continue; }
 
 		for(sp=p;*sp;sp++)
-			if(!isalnum(*sp) && *sp!='_')
+			if(!isalnum((uchar)*sp) && *sp!='_')
 				break;
 		sav[0]=*sp; 		/* Save delimiter */
 		sav[1]=0;
@@ -450,10 +450,12 @@ void expdefs(uchar *line)
 }
 
 
+#define SKIPCTRLSP(p) while(*(p)<=' ' && *(p)>0) (p)++
 
 void compile(char *src)
 {
-	uchar *str,*save,*p,*sp,*tp,*arg,*arg2,*arg3,*arg4,*ar,ch;
+	char *str,*save,*p,*sp,*tp,*arg,*arg2,*arg3,*arg4,ch;
+	uchar *ar;
 	char path[MAX_PATH+1];
 	uint16_t i;
     uint16_t j;
@@ -484,8 +486,7 @@ void compile(char *src)
 		line++;
 		strcpy(save,str);
 		p=str;
-		while(*p && *p<=' ')   /* look for beginning of command */
-			p++;
+		SKIPCTRLSP(p);   /* look for beginning of command */
 		if((*p)==0)
 			continue;
 		if(*p=='#')             /* remarks start with # */
@@ -498,19 +499,23 @@ void compile(char *src)
 		if(sp) {
 			*sp=0;
 			arg=sp+1;
-			while(*arg && *arg<=' ') arg++;
+			SKIPCTRLSP(arg);
 			sp=strchr(arg,' ');
 			if(sp) {
 				arg2=sp+1;
-				while(*arg2 && *arg2<=' ') arg2++;
+				SKIPCTRLSP(arg2);
 				sp=strchr(arg2,' ');
 				if(sp) {
 					arg3=sp+1;
-					while(*arg3 && *arg3<=' ') arg3++; 
+					SKIPCTRLSP(arg3);
 					sp=strchr(arg3,' ');
 					if(sp) {
 						arg4=sp+1;
-						while(*arg4 && *arg4<=' ') arg4++; } } } }
+						SKIPCTRLSP(arg4);
+					}
+				}
+			}
+		}
 
 		if(!stricmp(p,"!INCLUDE")) {
 			savline=line;
@@ -563,15 +568,15 @@ void compile(char *src)
 				if(!sp)
 					break;
 				p=sp+1;
-				while(*p && *p<=' ')
-					p++; }
+				SKIPCTRLSP(p);
+			}
 			continue; }
 
 		if(!stricmp(p,"PATCH")) {
 			if(!(*arg)) break;
 			p=arg;
 			while(*p) {
-				while(*p && *p<=' ') p++;
+				SKIPCTRLSP(p);
 				tmp[0]=*p++;
 				tmp[1]=*p++;
 				tmp[2]=0;
@@ -832,7 +837,7 @@ void compile(char *src)
 				ch=toupper(*arg);
 			if(ch=='/')
 				ch=*(arg+1)|0x80;   /* high bit indicates slash required */
-			else if(ch=='^' && *(arg+1)>=0x40)
+			else if(ch=='^' && (*(arg+1)>=0x40))
 				ch=*(arg+1)-0x40;   /* ctrl char */
 			else if(ch=='\\')
 				ch=cesc(*(arg+1));
@@ -869,8 +874,8 @@ void compile(char *src)
 				if(!sp)
 					break;
 				p=sp+1;
-				while(*p && *p<=' ')
-					p++; }
+				SKIPCTRLSP(p);
+			}
 			continue; }
 		if(!stricmp(p,"DEFINE_INT_VAR") || !stricmp(p,"INT")) {
 			if(!(*arg)) break;
@@ -884,8 +889,8 @@ void compile(char *src)
 				if(!sp)
 					break;
 				p=sp+1;
-				while(*p && *p<=' ')
-					p++; }
+				SKIPCTRLSP(p);
+			}
 			continue; }
 		if(!stricmp(p,"DEFINE_GLOBAL_STR_VAR") || !stricmp(p,"GLOBAL_STR")) {
 			if(!(*arg)) break;
@@ -899,8 +904,8 @@ void compile(char *src)
 				if(!sp)
 					break;
 				p=sp+1;
-				while(*p && *p<=' ')
-					p++; }
+				SKIPCTRLSP(p);
+			}
 			continue; }
 		if(!stricmp(p,"DEFINE_GLOBAL_INT_VAR") || !stricmp(p,"GLOBAL_INT")) {
 			if(!(*arg)) break;
@@ -914,8 +919,8 @@ void compile(char *src)
 				if(!sp)
 					break;
 				p=sp+1;
-				while(*p && *p<=' ')
-					p++; }
+				SKIPCTRLSP(p);
+			}
 			continue; }
 
 		if(!stricmp(p,"LOGIN")) {
@@ -1017,14 +1022,14 @@ void compile(char *src)
 			*p=0;
 			writecrc(src,arg);					/* Write destination variable */
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			arg=p;
 			p=strrchr(arg,'"');
 			if(!p)
 				break;
 			*p=0;
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			writecstr(arg);                 /* Write string */
 			l=ftell(out);
 			fputc(0,out);                   /* Write total number of args */
@@ -1052,7 +1057,7 @@ void compile(char *src)
 			*p=0;
 			writecrc(src,arg);					/* Write destination variable */
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			arg=p;
 			p=strrchr(arg,'"');
 			if(!p)
@@ -1060,7 +1065,7 @@ void compile(char *src)
 			*p=0;
 			writecstr(arg);                 /* Write string */
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			writecrc(src,p);
 			continue; }
 
@@ -1147,7 +1152,7 @@ void compile(char *src)
 				break;
 			*p=0;
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			writecrc(src,arg2);
 			writecstr(p);
 			continue; }
@@ -1173,14 +1178,14 @@ void compile(char *src)
 				break;
 			*p=0;
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			writecrc(src,arg2);
 			writecrc(src,p);
 			continue; }
 
 		if(!stricmp(p,"COMPARE_INT_VAR") ||
 			(!stricmp(p,"COMPARE")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 
 			fputc(CS_VAR_INSTRUCTION,out);
@@ -1285,7 +1290,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"ADD_INT_VAR")
 			|| (!stricmp(p,"ADD")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(ADD_INT_VAR,out);
@@ -1313,7 +1318,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"SUB_INT_VAR")
 			|| (!stricmp(p,"SUB")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(SUB_INT_VAR,out);
@@ -1341,7 +1346,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"MUL_INT_VAR")
 			|| (!stricmp(p,"MUL")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(MUL_INT_VAR,out);
@@ -1369,7 +1374,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"DIV_INT_VAR")
 			|| (!stricmp(p,"DIV")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(DIV_INT_VAR,out);
@@ -1397,7 +1402,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"MOD_INT_VAR")
 			|| (!stricmp(p,"MOD")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(MOD_INT_VAR,out);
@@ -1425,7 +1430,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"AND_INT_VAR")
 			|| (!stricmp(p,"AND")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(AND_INT_VAR,out);
@@ -1469,7 +1474,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"OR_INT_VAR")
 			|| (!stricmp(p,"OR")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(OR_INT_VAR,out);
@@ -1495,7 +1500,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"NOT_INT_VAR")
 			|| (!stricmp(p,"NOT")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(NOT_INT_VAR,out);
@@ -1521,7 +1526,7 @@ void compile(char *src)
 
 		if(!stricmp(p,"XOR_INT_VAR")
 			|| (!stricmp(p,"XOR")
-				&& (isdigit(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
+				&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
 			if(!(*arg)) break;
 			fputc(CS_VAR_INSTRUCTION,out);
 			fputc(XOR_INT_VAR,out);
@@ -1606,7 +1611,7 @@ void compile(char *src)
 				break;
 			*p=0;
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			writecstr(arg);                 /* Write string */
 			l=ftell(out);
 			fputc(0,out);                   /* Write total number of args */
@@ -1651,7 +1656,7 @@ void compile(char *src)
 			*p=0;
 			p++;
 			fwrite(&i,2,1,out);
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			if(*p=='"')
 				writestr(p);
 			else
@@ -1673,7 +1678,7 @@ void compile(char *src)
 			if(!(*arg)) break;
 
 			fputc(CS_FIO_FUNCTION,out);
-			if(!(*arg3) || isdigit(*arg3) || atoi(arg3))
+			if(!(*arg3) || isdigit((uchar)*arg3) || atoi(arg3))
 				fputc(FIO_READ,out);
 			else
 				fputc(FIO_READ_VAR,out);
@@ -1686,7 +1691,7 @@ void compile(char *src)
 			if(p)
 				*p=0;
 			writecrc(src,arg2); 		/* Variable */
-			if(isdigit(*arg3))
+			if(isdigit((uchar)*arg3))
 				i=val(src,arg3);	 /* Length */
 			else
 				i=0;
@@ -1698,7 +1703,7 @@ void compile(char *src)
 		if(!stricmp(p,"FWRITE")) {
 			if(!(*arg)) break;
 			fputc(CS_FIO_FUNCTION,out);
-			if(!(*arg3) || isdigit(*arg3) || atoi(arg3))
+			if(!(*arg3) || isdigit((uchar)*arg3) || atoi(arg3))
 				fputc(FIO_WRITE,out);
 			else
 				fputc(FIO_WRITE_VAR,out);
@@ -1711,7 +1716,7 @@ void compile(char *src)
 			if(p)
 				*p=0;
 			writecrc(src,arg2); 		/* Variable */
-			if(isdigit(*arg3))
+			if(isdigit((uchar)*arg3))
 				i=val(src,arg3);	 /* Length */
 			else
 				i=0;
@@ -1764,7 +1769,7 @@ void compile(char *src)
 		if(!stricmp(p,"FSET_POS") || !stricmp(p,"FSEEK")) {
 			if(!(*arg)) break;
 			fputc(CS_FIO_FUNCTION,out);
-			if(isdigit(*arg2) || atol(arg2))
+			if(isdigit((uchar)*arg2) || atol(arg2))
 				fputc(FIO_SEEK,out);
 			else
 				fputc(FIO_SEEK_VAR,out);
@@ -1776,7 +1781,7 @@ void compile(char *src)
 			p=strchr(arg2,' ');
 			if(p)
 				*p=0;
-			if(atol(arg2) || isdigit(*arg2)) {
+			if(atol(arg2) || isdigit((uchar)*arg2)) {
 				l=val(src,arg2);
 				fwrite(&l,4,1,out); }
 			else
@@ -1784,7 +1789,7 @@ void compile(char *src)
 			i=0;
 			if(p) {
 				p++;
-				while(*p && *p<=' ') p++;
+				SKIPCTRLSP(p);
 				i=atoi(p);
 				if(!stricmp(p,"CUR"))
 					i=SEEK_CUR;
@@ -1795,7 +1800,7 @@ void compile(char *src)
 		if(!stricmp(p,"FLOCK")) {
 			if(!(*arg)) break;
 			fputc(CS_FIO_FUNCTION,out);
-			if(isdigit(*arg2) || atol(arg2))
+			if(isdigit((uchar)*arg2) || atol(arg2))
 				fputc(FIO_LOCK,out);
 			else
 				fputc(FIO_LOCK_VAR,out);
@@ -1804,7 +1809,7 @@ void compile(char *src)
 				break;
 			*p=0;
 			writecrc(src,arg);			/* File handle */
-			if(atol(arg2) || isdigit(*arg2)) {
+			if(atol(arg2) || isdigit((uchar)*arg2)) {
 				l=val(src,arg2);
 				if(!l)
 					break;
@@ -1815,7 +1820,7 @@ void compile(char *src)
 		if(!stricmp(p,"FUNLOCK")) {
 			if(!(*arg)) break;
 			fputc(CS_FIO_FUNCTION,out);
-			if(isdigit(*arg2) || atol(arg2))
+			if(isdigit((uchar)*arg2) || atol(arg2))
 				fputc(FIO_UNLOCK,out);
 			else
 				fputc(FIO_UNLOCK_VAR,out);
@@ -1824,7 +1829,7 @@ void compile(char *src)
 				break;
 			*p=0;
 			writecrc(src,arg);			/* File handle */
-			if(atol(arg2) || isdigit(*arg2)) {
+			if(atol(arg2) || isdigit((uchar)*arg2)) {
 				l=val(src,arg2);
 				if(!l)
 					break;
@@ -1835,7 +1840,7 @@ void compile(char *src)
 		if(!stricmp(p,"FSET_LENGTH")) {
 			if(!(*arg)) break;
 			fputc(CS_FIO_FUNCTION,out);
-			if(isdigit(*arg2) || atol(arg2))
+			if(isdigit((uchar)*arg2) || atol(arg2))
 				fputc(FIO_SET_LENGTH,out);
 			else
 				fputc(FIO_SET_LENGTH_VAR,out);
@@ -1844,7 +1849,7 @@ void compile(char *src)
 				break;
 			*p=0;
 			writecrc(src,arg);			/* File handle */
-			if(atol(arg2) || isdigit(*arg2)) {
+			if(atol(arg2) || isdigit((uchar)*arg2)) {
 				l=val(src,arg2);
 				fwrite(&l,4,1,out); }
 			else
@@ -1860,14 +1865,14 @@ void compile(char *src)
 			*p=0;
 			writecrc(src,arg);					/* Write destination variable */
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			arg=p;
 			p=strrchr(arg,'"');
 			if(!p)
 				break;
 			*p=0;
 			p++;
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			writecstr(arg);                 /* Write string */
 			l=ftell(out);
 			fputc(0,out);                   /* Write total number of args */
@@ -2543,7 +2548,7 @@ void compile(char *src)
 		if(!stricmp(p,"GETSTR")) {
 			p=strchr(arg,' ');
 			if(p) *p=0;
-			if((!(*arg) || isdigit(*arg) || !stricmp(arg,"STR")) && !(*arg3))
+			if((!(*arg) || isdigit((uchar)*arg) || !stricmp(arg,"STR")) && !(*arg3))
 				fprintf(out,"%c%c",CS_GETSTR,atoi(arg) ? atoi(arg)
 					: *arg2 ? atoi(arg2) : 128);
 			else {
@@ -2572,7 +2577,7 @@ void compile(char *src)
 			if(!(*arg)) break;
 			p=strchr(arg,' ');
 			if(p) *p=0;
-			if(isdigit(*arg)) {
+			if(isdigit((uchar)*arg)) {
 				i=val(src,arg);
 				fprintf(out,"%c",CS_GETNUM);
 				fwrite(&i,2,1,out); }
@@ -2607,7 +2612,7 @@ void compile(char *src)
 		if(!stricmp(p,"GETLINE")) {
 			p=strchr(arg,' ');
 			if(p) *p=0;
-			if(!(*arg) || isdigit(*arg))
+			if(!(*arg) || isdigit((uchar)*arg))
 				fprintf(out,"%c%c",CS_GETLINE,*arg ? atoi(arg) :128);
 			else {
 				if((l=isvar(arg2))!=0) {
@@ -2627,7 +2632,7 @@ void compile(char *src)
 		if(!stricmp(p,"GETSTRUPR")) {
 			p=strchr(arg,' ');
 			if(p) *p=0;
-			if(!(*arg) || isdigit(*arg))
+			if(!(*arg) || isdigit((uchar)*arg))
 				fprintf(out,"%c%c",CS_GETSTRUPR,*arg ? atoi(arg) :128);
 			else {
 				if((l=isvar(arg2))!=0) {
@@ -2647,7 +2652,7 @@ void compile(char *src)
 		if(!stricmp(p,"GETNAME")) {
 			p=strchr(arg,' ');
 			if(p) *p=0;
-			if(!(*arg) || isdigit(*arg))
+			if(!(*arg) || isdigit((uchar)*arg))
 				fprintf(out,"%c%c",CS_GETNAME,*arg ? atoi(arg) :25);
 			else {
 				if((l=isvar(arg2))!=0) {
@@ -2668,7 +2673,7 @@ void compile(char *src)
 			if(!(*arg)) break;
 			p=strchr(arg,' ');
 			if(p) *p=0;
-			if(isdigit(*arg))
+			if(isdigit((uchar)*arg))
 				fprintf(out,"%c%c",CS_SHIFT_STR,atoi(arg));
 			else {
 				if((l=isvar(arg2))!=0) {
@@ -2844,7 +2849,7 @@ void compile(char *src)
 			if(!(*arg)) break;
 			p=arg;
 			fprintf(out,"%c%c",CS_TOGGLE_USER_FLAG,toupper(*p++));
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			fprintf(out,"%c",toupper(*p));
 			continue; }
 
diff --git a/src/sbbs3/chksmb.c b/src/sbbs3/chksmb.c
index ea5a533f17989d363fb3093d1b63d220b641a8b5..bb5f3ee5457061aa9adfaa233f8d87fdd25c3a12 100644
--- a/src/sbbs3/chksmb.c
+++ b/src/sbbs3/chksmb.c
@@ -347,7 +347,7 @@ int main(int argc, char **argv)
 
 		if(!(smb.status.attr&SMB_EMAIL) && chkhash) {
 			/* Look-up the message hashes */
-			hashes=smb_msghashes(&msg,body,SMB_HASH_SOURCE_DUPE);
+			hashes=smb_msghashes(&msg,(uchar*)body,SMB_HASH_SOURCE_DUPE);
 			if(hashes!=NULL 
 				&& hashes[0]!=NULL 
 				&& (i=smb_findhash(&smb,hashes,NULL,SMB_HASH_SOURCE_DUPE,/* mark */TRUE ))
@@ -373,7 +373,7 @@ int main(int argc, char **argv)
 						if(hashes[h]->flags&SMB_HASH_CRC32)
 							printf("%-10s: %08"PRIx32"\n","CRC-32",	hashes[h]->crc32);
 						if(hashes[h]->flags&SMB_HASH_MD5)
-							printf("%-10s: %s\n",	"MD5",		MD5_hex(str,hashes[h]->md5));
+							printf("%-10s: %s\n",	"MD5",		MD5_hex((BYTE*)str,hashes[h]->md5));
 
 #endif
 					}
diff --git a/src/sbbs3/delfiles.c b/src/sbbs3/delfiles.c
index a907fb7f8b863685cd4eac88da881b2ec485d44d..90945b5596db5976ec5050c42edfdca63849a3aa 100644
--- a/src/sbbs3/delfiles.c
+++ b/src/sbbs3/delfiles.c
@@ -229,7 +229,7 @@ int main(int argc, char **argv)
 		if(!l) {
 			close(file);
 			continue; }
-		if((ixbbuf=(char *)malloc(l))==NULL) {
+		if((ixbbuf=malloc(l))==NULL) {
 			close(file);
 			printf("\7ERR_ALLOC %s %lu\n",str,l);
 			continue; }
diff --git a/src/sbbs3/filelist.c b/src/sbbs3/filelist.c
index 08477862eef044c441e4a3f7765f1c374e8cca24..69aa8fe1c696c5126fc2231754289adbcc43e6c7 100644
--- a/src/sbbs3/filelist.c
+++ b/src/sbbs3/filelist.c
@@ -312,7 +312,7 @@ int main(int argc, char **argv)
 			close(file);
 			if(misc&AUTO) fclose(out);
 			continue; }
-		if((ixbbuf=(char *)malloc(l))==NULL) {
+		if((ixbbuf=(uchar *)malloc(l))==NULL) {
 			close(file);
 			if(misc&AUTO) fclose(out);
 			printf("\7ERR_ALLOC %s %lu\n",str,l);
diff --git a/src/sbbs3/fixsmb.c b/src/sbbs3/fixsmb.c
index 2fc4d085854f76aa78e3575fb90e797bd5dac2fb..88cb24ce9232ae1559b15fcfaa5cb2a3a476cbe5 100644
--- a/src/sbbs3/fixsmb.c
+++ b/src/sbbs3/fixsmb.c
@@ -204,7 +204,7 @@ int fixsmb(char* sub)
 			text=NULL;
 		else
 			text=smb_getmsgtxt(&smb,&msg,GETMSGTXT_BODY_ONLY);
-		i=smb_hashmsg(&smb,&msg,text,TRUE /* update */);
+		i=smb_hashmsg(&smb,&msg,(uchar*)text,TRUE /* update */);
 		if(i!=SMB_SUCCESS)
 			printf("!ERROR %d hashing message\n", i);
 		if(text!=NULL)
diff --git a/src/sbbs3/ftpsrvr.c b/src/sbbs3/ftpsrvr.c
index 7562982b2496cb03975718337d2af5b911c3479e..4d3424babbbf0c46db600a60e5966ba62daafb01 100644
--- a/src/sbbs3/ftpsrvr.c
+++ b/src/sbbs3/ftpsrvr.c
@@ -79,8 +79,8 @@
 static ftp_startup_t*	startup=NULL;
 static scfg_t	scfg;
 static SOCKET	server_socket=INVALID_SOCKET;
-static protected_int32_t active_clients;
-static protected_int32_t thread_count;
+static protected_uint32_t active_clients;
+static protected_uint32_t thread_count;
 static volatile time_t	uptime=0;
 static volatile ulong	served=0;
 static volatile BOOL	terminate_server=FALSE;
@@ -208,7 +208,7 @@ static void client_off(SOCKET sock)
 
 static int32_t thread_up(BOOL setuid)
 {
-	int32_t	count =	protected_int32_adjust(&thread_count,1);
+	int32_t	count =	protected_uint32_adjust(&thread_count,1);
 	if(startup!=NULL && startup->thread_up!=NULL)
 		startup->thread_up(startup->cbdata,TRUE, setuid);
 	return count;
@@ -216,7 +216,7 @@ static int32_t thread_up(BOOL setuid)
 
 static int32_t thread_down(void)
 {
-	int32_t count = protected_int32_adjust(&thread_count,-1);
+	int32_t count = protected_uint32_adjust(&thread_count,-1);
 	if(startup!=NULL && startup->thread_up!=NULL)
 		startup->thread_up(startup->cbdata,FALSE, FALSE);
 	return count;
@@ -2400,7 +2400,7 @@ static void ctrl_thread(void* arg)
 		return;
 	} 
 
-	protected_int32_adjust(&active_clients, 1), 
+	protected_uint32_adjust(&active_clients, 1), 
 	update_clients();
 
 	/* Initialize client display */
@@ -4478,7 +4478,7 @@ static void ctrl_thread(void* arg)
 	ftp_close_socket(&tmp_sock,__LINE__);
 
 	{
-		int32_t	clients = protected_int32_adjust(&active_clients, -1);
+		int32_t	clients = protected_uint32_adjust(&active_clients, -1);
 		int32_t	threads = thread_down();
 		update_clients();
 
@@ -4512,7 +4512,7 @@ static void cleanup(int code, int line)
 	if(active_clients.value)
 		lprintf(LOG_WARNING,"#### !FTP Server terminating with %ld active clients", active_clients.value);
 	else
-		protected_int32_destroy(active_clients);
+		protected_uint32_destroy(active_clients);
 
 	update_clients();
 
@@ -4627,7 +4627,7 @@ void DLLCALL ftp_server(void* arg)
 	startup->recycle_now=FALSE;
 	startup->shutdown_now=FALSE;
 	terminate_server=FALSE;
-	protected_int32_init(&thread_count, 0);
+	protected_uint32_init(&thread_count, 0);
 
 	do {
 
@@ -4723,7 +4723,7 @@ void DLLCALL ftp_server(void* arg)
 
 		lprintf(LOG_DEBUG,"Maximum inactivity: %d seconds",startup->max_inactivity);
 
-		protected_int32_init(&active_clients, 0);
+		protected_uint32_init(&active_clients, 0);
 		update_clients();
 
 		strlwr(scfg.sys_id); /* Use lower-case unix-looking System ID for group name */
@@ -4921,5 +4921,5 @@ void DLLCALL ftp_server(void* arg)
 
 	} while(!terminate_server);
 
-	protected_int32_destroy(thread_count);
+	protected_uint32_destroy(thread_count);
 }
diff --git a/src/sbbs3/getmail.c b/src/sbbs3/getmail.c
index fb436056054b59d393cebddbf7e0c2af6e32a4d1..9a99da867a2bceaf531ccb6538dc7d4609dc4957 100644
--- a/src/sbbs3/getmail.c
+++ b/src/sbbs3/getmail.c
@@ -122,7 +122,7 @@ void DLLCALL delfattach(scfg_t* cfg, smbmsg_t* msg)
 /* of pointers to mail_t (message numbers and attributes)                   */
 /* smb_open(&smb) must be called prior										*/
 /****************************************************************************/
-mail_t* DLLCALL loadmail(smb_t* smb, int32_t* msgs, uint usernumber
+mail_t* DLLCALL loadmail(smb_t* smb, uint32_t* msgs, uint usernumber
 			   ,int which, long mode)
 {
 	ulong		l=0;
diff --git a/src/sbbs3/mail.cpp b/src/sbbs3/mail.cpp
index 863754ce89728275c3dd26a9aa3cbbf542a5a384..0f344d3cb4e0a8a1aa42d879bdc033ece0f8f273 100644
--- a/src/sbbs3/mail.cpp
+++ b/src/sbbs3/mail.cpp
@@ -79,7 +79,7 @@ int sbbs_t::delmail(uint usernumber, int which)
 				|| (which==MAIL_YOUR && usernumber==msg.idx.to)
 				|| (which==MAIL_ANY	&& (usernumber==msg.idx.to || usernumber==msg.idx.from))
 				|| which==MAIL_ALL)) {
-			if(smb.status.max_age && now>msg.idx.time
+			if(smb.status.max_age && (now<0?0:(uintmax_t)now)>msg.idx.time
 				&& (now-msg.idx.time)/(24L*60L*60L)>smb.status.max_age)
 				msg.idx.attr|=MSG_DELETE;
 			else if(msg.idx.attr&MSG_KILLREAD && msg.idx.attr&MSG_READ)
@@ -163,11 +163,11 @@ void sbbs_t::telluser(smbmsg_t* msg)
 /************************************************************************/
 void sbbs_t::delallmail(uint usernumber, int which, bool permanent)
 {
-	int 	i;
-	long	l,deleted=0;
-	int32_t	msgs;
-	mail_t	*mail;
-	smbmsg_t msg;
+	int 		i;
+	long		deleted=0;
+	uint32_t	msgs,u;
+	mail_t		*mail;
+	smbmsg_t 	msg;
 
 	if((i=smb_stack(&smb,SMB_STACK_PUSH))!=0) {
 		errormsg(WHERE,ERR_OPEN,"MAIL",i);
@@ -195,11 +195,11 @@ void sbbs_t::delallmail(uint usernumber, int which, bool permanent)
 		errormsg(WHERE,ERR_LOCK,smb.file,i,smb.last_error);	/* messes with the index */
 		return; 
 	}
-	for(l=0;l<msgs;l++) {
+	for(u=0;u<msgs;u++) {
 		msg.idx.offset=0;						/* search by number */
-		if((mail[l].attr&MSG_PERMANENT) && !permanent)
+		if((mail[u].attr&MSG_PERMANENT) && !permanent)
 			continue;
-		if(loadmsg(&msg,mail[l].number)) {	   /* message still there */
+		if(loadmsg(&msg,mail[u].number)) {	   /* message still there */
 			msg.hdr.attr|=MSG_DELETE;
 			msg.hdr.attr&=~MSG_PERMANENT;
 			msg.idx.attr=msg.hdr.attr;
diff --git a/src/sbbs3/mailsrvr.c b/src/sbbs3/mailsrvr.c
index ad766a9b71d572cc4af028943b9af201ea1ece63..46f5e6800877c685dffcba947952f725ffb64c68 100644
--- a/src/sbbs3/mailsrvr.c
+++ b/src/sbbs3/mailsrvr.c
@@ -90,8 +90,8 @@ static scfg_t	scfg;
 static SOCKET	server_socket=INVALID_SOCKET;
 static SOCKET	submission_socket=INVALID_SOCKET;
 static SOCKET	pop3_socket=INVALID_SOCKET;
-static protected_int32_t active_clients;
-static protected_int32_t thread_count;
+static protected_uint32_t active_clients;
+static protected_uint32_t thread_count;
 static volatile int		active_sendmail=0;
 static volatile BOOL	sendmail_running=FALSE;
 static volatile BOOL	terminate_server=FALSE;
@@ -218,7 +218,7 @@ static void client_off(SOCKET sock)
 
 static int32_t thread_up(BOOL setuid)
 {
-	int32_t	count =	protected_int32_adjust(&thread_count,1);
+	int32_t	count =	protected_uint32_adjust(&thread_count,1);
 	if(startup!=NULL && startup->thread_up!=NULL)
 		startup->thread_up(startup->cbdata,TRUE,setuid);
 	return count;
@@ -226,7 +226,7 @@ static int32_t thread_up(BOOL setuid)
 
 static int32_t thread_down(void)
 {
-	int32_t count = protected_int32_adjust(&thread_count,-1);
+	int32_t count = protected_uint32_adjust(&thread_count,-1);
 	if(startup!=NULL && startup->thread_up!=NULL)
 		startup->thread_up(startup->cbdata,FALSE,FALSE);
 	return count;
@@ -471,7 +471,7 @@ static ulong sockmimetext(SOCKET socket, smbmsg_t* msg, char* msgtxt, ulong maxl
 	char		msgid[256];
 	char		date[64];
 	uchar*		p;
-	uchar*		np;
+	char*		np;
 	char*		content_type=NULL;
 	int			i;
 	int			s;
@@ -600,24 +600,24 @@ static ulong sockmimetext(SOCKET socket, smbmsg_t* msg, char* msgtxt, ulong maxl
 
 	/* MESSAGE BODY */
 	lines=0;
-	p=msgtxt;
-	while(*p && lines<maxlines) {
+	np=msgtxt;
+	while(*np && lines<maxlines) {
 		len=0;
-		while(len<MAX_LINE_LEN && *(p+len)!=0 && *(p+len)!='\n')
+		while(len<MAX_LINE_LEN && *(np+len)!=0 && *(np+len)!='\n')
 			len++;
 
 		tlen=len;
-		while(tlen && *(p+(tlen-1))<=' ') /* Takes care of '\r' or spaces */
+		while(tlen && *(np+(tlen-1))<=' ') /* Takes care of '\r' or spaces */
 			tlen--;
 
-		if(!sockprintf(socket, "%s%.*s", *p=='.' ? ".":"", tlen, p))
+		if(!sockprintf(socket, "%s%.*s", *np=='.' ? ".":"", tlen, np))
 			break;
 		lines++;
-		if(*(p+len)=='\r')
+		if(*(np+len)=='\r')
 			len++;
-		if(*(p+len)=='\n')
+		if(*(np+len)=='\n')
 			len++;
-		p+=len;
+		np+=len;
 		/* release time-slices every x lines */
 		if(startup->lines_per_yield
 			&& !(lines%startup->lines_per_yield))	
@@ -756,7 +756,7 @@ static void pop3_thread(void* arg)
 	char		username[128];
 	char		password[128];
 	char		challenge[256];
-	char		digest[MD5_DIGEST_SIZE];
+	uchar		digest[MD5_DIGEST_SIZE];
 	char*		response="";
 	char*		msgtxt;
 	int			i;
@@ -767,7 +767,7 @@ static void pop3_thread(void* arg)
 	ulong		lines;
 	ulong		lines_sent;
 	ulong		login_attempts;
-	int32_t		msgs;
+	uint32_t	msgs;
 	long		msgnum;
 	ulong		bytes;
 	SOCKET		socket;
@@ -832,7 +832,7 @@ static void pop3_thread(void* arg)
 		return;
 	}
 
-	protected_int32_adjust(&active_clients, 1);
+	protected_uint32_adjust(&active_clients, 1);
 	update_clients();
 
 	/* Initialize client display */
@@ -932,7 +932,7 @@ static void pop3_thread(void* arg)
 			strlwr(user.pass);	/* this is case-sensitive, so convert to lowercase */
 			strcat(challenge,user.pass);
 			MD5_calc(digest,challenge,strlen(challenge));
-			MD5_hex(str,digest);
+			MD5_hex((BYTE*)str,digest);
 			if(strcmp(str,response)) {
 				lprintf(LOG_NOTICE,"%04d !POP3 %s FAILED APOP authentication"
 					,socket,username);
@@ -1354,7 +1354,7 @@ static void pop3_thread(void* arg)
 	smb_freemsgmem(&msg);
 	smb_close(&smb);
 
-	protected_int32_adjust(&active_clients, -1);
+	protected_uint32_adjust(&active_clients, -1);
 	update_clients();
 	client_off(socket);
 
@@ -1935,9 +1935,9 @@ void js_cleanup(JSRuntime* js_runtime, JSContext* js_cx, JSObject** js_glob)
 }
 #endif
 
-static uchar* get_header_field(uchar* buf, char* name, size_t maxlen)
+static char* get_header_field(char* buf, char* name, size_t maxlen)
 {
-	uchar*	p;
+	char*	p;
 	size_t	len;
 
 	if(buf[0]<=' ')	/* folded header */
@@ -1957,7 +1957,7 @@ static uchar* get_header_field(uchar* buf, char* name, size_t maxlen)
 	return p;
 }
 
-static int parse_header_field(uchar* buf, smbmsg_t* msg, ushort* type)
+static int parse_header_field(char* buf, smbmsg_t* msg, ushort* type)
 {
 	char*	p;
 	char*	tp;
@@ -2122,10 +2122,10 @@ static void parse_mail_address(char* p
 /* Decode quoted-printable content-transfer-encoded text */
 /* Ignores (strips) unsupported ctrl chars and non-ASCII chars */
 /* Does not enforce 76 char line length limit */
-static char* qp_decode(uchar* buf)
+static char* qp_decode(char* buf)
 {
-	uchar*	p=buf;
-	uchar*	dest=buf;
+	uchar*	p=(uchar*)buf;
+	uchar*	dest=p;
 
 	for(;;p++) {
 		if(*p==0) {
@@ -2253,7 +2253,7 @@ static void smtp_thread(void* arg)
 	char		response[128];
 	char		secret[64];
 	char		md5_data[384];
-	char		digest[MD5_DIGEST_SIZE];
+	uchar		digest[MD5_DIGEST_SIZE];
 	char		dest_host[128];
 	char*		errmsg;
 	ushort		dest_port;
@@ -2394,7 +2394,7 @@ static void smtp_thread(void* arg)
 	if(!(startup->options&MAIL_OPT_NO_HOST_LOOKUP))
 		lprintf(LOG_INFO,"%04d SMTP Hostname: %s", socket, host_name);
 
-	protected_int32_adjust(&active_clients, 1);
+	protected_uint32_adjust(&active_clients, 1);
 	update_clients();
 
 	SAFECOPY(hello_name,host_name);
@@ -2415,7 +2415,7 @@ static void smtp_thread(void* arg)
 			sockprintf(socket,"550 CLIENT IP ADDRESS BLOCKED: %s", host_ip);
 			mail_close_socket(socket);
 			thread_down();
-			protected_int32_adjust(&active_clients, -1);
+			protected_uint32_adjust(&active_clients, -1);
 			update_clients();
 			return;
 		}
@@ -2427,7 +2427,7 @@ static void smtp_thread(void* arg)
 			sockprintf(socket,"550 CLIENT HOSTNAME BLOCKED: %s", host_name);
 			mail_close_socket(socket);
 			thread_down();
-			protected_int32_adjust(&active_clients, -1);
+			protected_uint32_adjust(&active_clients, -1);
 			update_clients();
 			return;
 		}
@@ -2447,7 +2447,7 @@ static void smtp_thread(void* arg)
 				lprintf(LOG_NOTICE,"%04d !SMTP REFUSED SESSION from blacklisted server (%u total)"
 					,socket, ++stats.sessions_refused);
 				thread_down();
-				protected_int32_adjust(&active_clients, -1);
+				protected_uint32_adjust(&active_clients, -1);
 				update_clients();
 				return;
 			}
@@ -2461,7 +2461,7 @@ static void smtp_thread(void* arg)
 		sockprintf(socket,sys_unavail);
 		mail_close_socket(socket);
 		thread_down();
-		protected_int32_adjust(&active_clients, -1);
+		protected_uint32_adjust(&active_clients, -1);
 		update_clients();
 		return;
 	}
@@ -2484,7 +2484,7 @@ static void smtp_thread(void* arg)
 		sockprintf(socket,sys_error);
 		mail_close_socket(socket);
 		thread_down();
-		protected_int32_adjust(&active_clients, -1);
+		protected_uint32_adjust(&active_clients, -1);
 		update_clients();
 		return;
 	}
@@ -2834,7 +2834,7 @@ static void smtp_thread(void* arg)
 							break;
 						}
 					}
-					if((smb_error=parse_header_field(buf,&msg,&hfield_type))!=SMB_SUCCESS) {
+					if((smb_error=parse_header_field((char*)buf,&msg,&hfield_type))!=SMB_SUCCESS) {
 						if(smb_error==SMB_ERR_HDR_LEN)
 							lprintf(LOG_WARNING,"%04d !SMTP MESSAGE HEADER EXCEEDS %u BYTES"
 								,socket, SMB_MAX_HDR_LEN);
@@ -2988,7 +2988,7 @@ static void smtp_thread(void* arg)
 						sources&=~(1<<SMB_HASH_SOURCE_SUBJECT);
 					lprintf(LOG_DEBUG,"%04d SMTP Calculating message hashes (sources=%lx, msglen=%u)"
 						,socket, sources, strlen(msgbuf));
-					if((hashes=smb_msghashes(&msg, msgbuf, sources)) != NULL) {
+					if((hashes=smb_msghashes(&msg, (uchar*)msgbuf, sources)) != NULL) {
 						hash_t	found;
 
 						for(i=0;hashes[i];i++)
@@ -3443,7 +3443,7 @@ static void smtp_thread(void* arg)
 				md5_data[i]=secret[i]^0x5c;	/* opad */
 			memcpy(md5_data+i,digest,sizeof(digest));
 			MD5_calc(digest,md5_data,sizeof(secret)+sizeof(digest));
-			MD5_hex(str,digest);
+			MD5_hex((BYTE*)str,digest);
 			if(strcmp(p,str)) {
 				lprintf(LOG_WARNING,"%04d !SMTP %s FAILED CRAM-MD5 authentication"
 					,socket,relay_user.alias);
@@ -4071,7 +4071,7 @@ static void smtp_thread(void* arg)
 
 	status(STATUS_WFC);
 
-	protected_int32_adjust(&active_clients, -1);
+	protected_uint32_adjust(&active_clients, -1);
 	update_clients();
 	client_off(socket);
 
@@ -4254,7 +4254,7 @@ static void sendmail_thread(void* arg)
 	char		challenge[256];
 	char		secret[64];
 	char		md5_data[384];
-	char		digest[MD5_DIGEST_SIZE];
+	uchar		digest[MD5_DIGEST_SIZE];
 	char		numeric_ip[16];
 	char		domain_list[MAX_PATH+1];
 	char		dns_server[16];
@@ -4277,8 +4277,8 @@ static void sendmail_thread(void* arg)
 	smb_t		smb;
 	smbmsg_t	msg;
 	mail_t*		mail;
-	int32_t		msgs;
-	long		l;
+	uint32_t	msgs;
+	uint32_t	u;
 	size_t		len;
 	BOOL		sending_locally=FALSE;
 	link_list_t	failed_server_list;
@@ -4346,7 +4346,7 @@ static void sendmail_thread(void* arg)
 		last_msg=smb.status.last_msg;
 		last_scan=time(NULL);
 		mail=loadmail(&smb,&msgs,/* to network */0,MAIL_YOUR,0);
-		for(l=0; l<msgs; l++) {
+		for(u=0; u<msgs; u++) {
 			if(active_sendmail!=0)
 				active_sendmail=0, update_clients();
 
@@ -4365,10 +4365,10 @@ static void sendmail_thread(void* arg)
 
 			smb_freemsgmem(&msg);
 
-			msg.hdr.number=mail[l].number;
+			msg.hdr.number=mail[u].number;
 			if((i=smb_getmsgidx(&smb,&msg))!=SMB_SUCCESS) {
 				lprintf(LOG_ERR,"0000 !SEND ERROR %d (%s) getting message index #%lu"
-					,i, smb.last_error, mail[l].number);
+					,i, smb.last_error, mail[u].number);
 				break;
 			}
 			if((i=smb_lockmsghdr(&smb,&msg))!=SMB_SUCCESS) {
@@ -4409,9 +4409,9 @@ static void sendmail_thread(void* arg)
 			truncstr(fromaddr," ");
 
 			lprintf(LOG_INFO,"0000 SEND Message #%lu (%u of %u) from %s%s %s to %s [%s]"
-				,msg.hdr.number, l+1, msgs, msg.from, fromext, fromaddr
+				,msg.hdr.number, u+1, msgs, msg.from, fromext, fromaddr
 				,msg.to, msg.to_net.addr);
-			SAFEPRINTF2(str,"Sending (%u of %u)", l+1, msgs);
+			SAFEPRINTF2(str,"Sending (%u of %u)", u+1, msgs);
 			status(str);
 #ifdef _WIN32
 			if(startup->outbound_sound[0] && !(startup->options&MAIL_OPT_MUTE)) 
@@ -4671,7 +4671,7 @@ static void sendmail_thread(void* arg)
 							memcpy(md5_data+i,digest,sizeof(digest));
 							MD5_calc(digest,md5_data,sizeof(secret)+sizeof(digest));
 							
-							safe_snprintf(buf,sizeof(buf),"%s %s",startup->relay_user,MD5_hex(str,digest));
+							safe_snprintf(buf,sizeof(buf),"%s %s",startup->relay_user,MD5_hex((BYTE*)str,digest));
 							b64_encode(p=resp,sizeof(resp),buf,0);
 							break;
 						default:
@@ -4853,7 +4853,7 @@ static void cleanup(int code)
 	if(active_clients.value)
 		lprintf(LOG_WARNING,"#### !Mail Server terminating with %ld active clients", active_clients.value);
 	else
-		protected_int32_destroy(active_clients);
+		protected_uint32_destroy(active_clients);
 
 	update_clients();
 
@@ -4992,7 +4992,7 @@ void DLLCALL mail_server(void* arg)
 	terminate_server=FALSE;
 
 	SetThreadName("Mail Server");
-	protected_int32_init(&thread_count, 0);
+	protected_uint32_init(&thread_count, 0);
 
 	do {
 
@@ -5118,7 +5118,7 @@ void DLLCALL mail_server(void* arg)
 
 		lprintf(LOG_DEBUG,"Maximum inactivity: %u seconds",startup->max_inactivity);
 
-		protected_int32_init(&active_clients, 0);
+		protected_uint32_init(&active_clients, 0);
 		update_clients();
 
 		/* open a socket and wait for a client */
@@ -5543,5 +5543,5 @@ void DLLCALL mail_server(void* arg)
 
 	} while(!terminate_server);
 
-	protected_int32_destroy(thread_count);
+	protected_uint32_destroy(thread_count);
 }
diff --git a/src/sbbs3/msgtoqwk.cpp b/src/sbbs3/msgtoqwk.cpp
index bdd60779d83f138eff6fbc7cdfe8fc3467e16b3b..b158c8b1fa28e4e633cd2100c98d42081c491e4a 100644
--- a/src/sbbs3/msgtoqwk.cpp
+++ b/src/sbbs3/msgtoqwk.cpp
@@ -44,7 +44,7 @@
 /* Converts message 'msg' to QWK format, writing to file 'qwk_fp'.          */
 /* mode determines how to handle Ctrl-A codes								*/
 /****************************************************************************/
-ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum
+ulong sbbs_t::msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, uint subnum
 	, int conf, FILE* hdrs)
 {
 	char	str[512],from[512],to[512],ch=0,tear=0,tearwatch=0,*buf,*p;
diff --git a/src/sbbs3/mxlookup.c b/src/sbbs3/mxlookup.c
index 5005295f2654c3f7dba8da9ab08f56958be2b6f9..b8826f49e7977cf179a8a77b874beb1bb28b59db 100644
--- a/src/sbbs3/mxlookup.c
+++ b/src/sbbs3/mxlookup.c
@@ -127,7 +127,7 @@ enum {
 	int mail_close_socket(SOCKET sock);
 #endif
 
-size_t dns_name(BYTE* name, size_t* namelen, size_t maxlen, BYTE* srcbuf, BYTE* p)
+size_t dns_name(char* name, size_t* namelen, size_t maxlen, BYTE* srcbuf, char* p)
 {
 	size_t	len=0;
 	size_t	plen;
@@ -140,7 +140,7 @@ size_t dns_name(BYTE* name, size_t* namelen, size_t maxlen, BYTE* srcbuf, BYTE*
 			(*p)&=~0xC0;
 			offset=ntohs(*(WORD*)p);
 			(*p)|=0xC0;
-			dns_name(name, namelen, maxlen, srcbuf, srcbuf+offset);
+			dns_name(name, namelen, maxlen, srcbuf, (char*)srcbuf+offset);
 			return(len+2);
 		}
 		plen=(*p);
@@ -176,8 +176,8 @@ void dump(BYTE* buf, int len)
 int dns_getmx(char* name, char* mx, char* mx2
 			  ,DWORD intf, DWORD ip_addr, BOOL use_tcp, int timeout)
 {
-	BYTE*			p;
-	BYTE*			tp;
+	char*			p;
+	char*			tp;
 	char			hostname[128];
 	size_t			namelen;
 	WORD			pref;
@@ -340,9 +340,9 @@ int dns_getmx(char* name, char* mx, char* mx2
 			offset=sizeof(msghdr.length);
 
 		answers=ntohs(msghdr.ancount);
-		p=msg+len;	/* Skip the header and question portion */
+		p=(char*)msg+len;	/* Skip the header and question portion */
 
-		for(i=0;i<answers && p<msg+sizeof(msg);i++) {
+		for(i=0;i<answers && p<(char*)msg+sizeof(msg);i++) {
 			namelen=0;
 			p+=dns_name(hostname, &namelen, sizeof(hostname)-1, msg+offset, p);
 
diff --git a/src/sbbs3/pack_qwk.cpp b/src/sbbs3/pack_qwk.cpp
index 4aa377136a9c6577ab91d984a69b78a20e203c7d..e074b3039f757379a6cc3c4743ce1455a4799630 100644
--- a/src/sbbs3/pack_qwk.cpp
+++ b/src/sbbs3/pack_qwk.cpp
@@ -49,8 +49,9 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
 	int 	mode;
 	uint	i,j,k,conf;
 	long	l,size,msgndx,ex;
-	int32_t	posts;
-	int32_t	mailmsgs=0;
+	uint32_t posts;
+	uint32_t mailmsgs=0;
+	uint32_t u;
 	ulong	totalcdt,totaltime
 			,files,submsgs,msgs,netfiles=0,preqwk=0;
 	uint32_t	lastmsg;
@@ -362,15 +363,15 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
 			else
 				mode&=~QM_TO_QNET;
 
-			for(l=0;l<mailmsgs;l++) {
+			for(u=0;u<mailmsgs;u++) {
 				bprintf("\b\b\b\b\b\b\b\b\b\b\b\b%4lu of %-4lu"
-					,l+1,mailmsgs);
+					,u+1,mailmsgs);
 
 				memset(&msg,0,sizeof(msg));
-				msg.idx=mail[l];
+				msg.idx=mail[u];
 				if(msg.idx.number>qwkmail_last)
 					qwkmail_last=msg.idx.number;
-				if(!loadmsg(&msg,mail[l].number))
+				if(!loadmsg(&msg,mail[u].number))
 					continue;
 
 				if(msg.hdr.auxattr&MSG_FILEATTACH && useron.qwk&QWK_ATTACH) {
@@ -481,15 +482,15 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
 				else
 					ndx=NULL;
 
-				for(l=0;l<posts && !msgabort();l++) {
-					bprintf("\b\b\b\b\b%-5lu",l+1);
+				for(u=0;u<posts && !msgabort();u++) {
+					bprintf("\b\b\b\b\b%-5lu",u+1);
 
-					subscan[usrsub[i][j]].ptr=post[l].number;	/* set ptr */
-					subscan[usrsub[i][j]].last=post[l].number; /* set last read */
+					subscan[usrsub[i][j]].ptr=post[u].number;	/* set ptr */
+					subscan[usrsub[i][j]].last=post[u].number; /* set last read */
 
 					memset(&msg,0,sizeof(msg));
-					msg.idx=post[l];
-					if(!loadmsg(&msg,post[l].number))
+					msg.idx=post[u];
+					if(!loadmsg(&msg,post[u].number))
 						continue;
 
 					if(useron.rest&FLAG('Q')) {
@@ -539,7 +540,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
 						bputs(text[QWKmsgLimitReached]);
 						break; 
 					} 
-					if(!(l%50))
+					if(!(u%50))
 						YIELD();	/* yield */
 				}
 				if(!(sys_status&SS_ABORT))
@@ -552,7 +553,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
 				}
 				smb_close(&smb);
 				free(post);
-				if(l<posts)
+				if(u<posts)
 					break; 
 				YIELD();	/* yield */
 			}
diff --git a/src/sbbs3/pack_rep.cpp b/src/sbbs3/pack_rep.cpp
index 677a825f5bbd659afe4530c83d7d6858d34223f4..08d15726ba3113a8d61615d5d963345c589202b5 100644
--- a/src/sbbs3/pack_rep.cpp
+++ b/src/sbbs3/pack_rep.cpp
@@ -50,9 +50,10 @@ bool sbbs_t::pack_rep(uint hubnum)
 	char		hubid_lower[LEN_QWKID+1];
 	int 		file,mode;
 	uint		i,j,k;
-	long		l,msgcnt,submsgs,packedmail,netfiles=0,deleted;
-	int32_t		posts;
-	int32_t		mailmsgs;
+	long		msgcnt,submsgs,packedmail,netfiles=0,deleted;
+	uint32_t	u;
+	uint32_t	posts;
+	uint32_t	mailmsgs;
 	ulong		msgs;
 	uint32_t	last;
 	post_t*		post;
@@ -122,14 +123,14 @@ bool sbbs_t::pack_rep(uint hubnum)
 	packedmail=0;
 	if(mailmsgs) {
 		eprintf(LOG_INFO,"Packing NetMail for %s", cfg.qhub[hubnum]->id);
-		for(l=0;l<mailmsgs;l++) {
-	//		bprintf("\b\b\b\b\b%-5lu",l+1);
+		for(u=0;u<mailmsgs;u++) {
+	//		bprintf("\b\b\b\b\b%-5lu",u+1);
 
 			memset(&msg,0,sizeof(msg));
-			msg.idx=mail[l];
+			msg.idx=mail[u];
 			if(msg.idx.number>qwkmail_last)
 				qwkmail_last=msg.idx.number;
-			if(!loadmsg(&msg,mail[l].number))
+			if(!loadmsg(&msg,mail[u].number))
 				continue;
 
 			SAFEPRINTF(str,"%s/",cfg.qhub[hubnum]->id);
@@ -189,12 +190,12 @@ bool sbbs_t::pack_rep(uint hubnum)
 		subscan[j].ptr=last;                   /* set pointer */
 		eprintf(LOG_INFO,"%s",remove_ctrl_a(text[QWKPackingSubboard],tmp));	/* ptr to last msg	*/
 		submsgs=0;
-		for(l=0;l<posts;l++) {
-	//		bprintf("\b\b\b\b\b%-5lu",l+1);
+		for(u=0;u<posts;u++) {
+	//		bprintf("\b\b\b\b\b%-5lu",u+1);
 
 			memset(&msg,0,sizeof(msg));
-			msg.idx=post[l];
-			if(!loadmsg(&msg,post[l].number))
+			msg.idx=post[u];
+			if(!loadmsg(&msg,post[u].number))
 				continue;
 
 			if(msg.from_net.type && msg.from_net.type!=NET_QWK &&
@@ -222,7 +223,7 @@ bool sbbs_t::pack_rep(uint hubnum)
 			smb_unlockmsghdr(&smb,&msg);
 			msgcnt++;
 			submsgs++; 
-			if(!(l%50))
+			if(!(u%50))
 				YIELD(); /* yield */
 		}
 		eprintf(LOG_INFO,remove_ctrl_a(text[QWKPackedSubboard],tmp),submsgs,msgcnt);
@@ -304,12 +305,12 @@ bool sbbs_t::pack_rep(uint hubnum)
 
 		deleted=0;
 		/* Mark as READ and DELETE */
-		for(l=0;l<mailmsgs;l++) {
-			if(mail[l].number>qwkmail_last)
+		for(u=0;u<mailmsgs;u++) {
+			if(mail[u].number>qwkmail_last)
 				continue;
 			memset(&msg,0,sizeof(msg));
 			/* !IMPORTANT: search by number (do not initialize msg.idx.offset) */
-			if(!loadmsg(&msg,mail[l].number))
+			if(!loadmsg(&msg,mail[u].number))
 				continue;
 
 			SAFEPRINTF(str,"%s/",cfg.qhub[hubnum]->id);
diff --git a/src/sbbs3/qwk.cpp b/src/sbbs3/qwk.cpp
index 5a0d4ef6510d804e8546d4d99190119eca94d71d..e4328bb6ce63aabc07ec393dfa9f7ad63b18f044 100644
--- a/src/sbbs3/qwk.cpp
+++ b/src/sbbs3/qwk.cpp
@@ -337,8 +337,8 @@ void sbbs_t::qwk_success(ulong msgcnt, char bi, char prepack)
 {
 	char	str[MAX_PATH+1];
 	int 	i;
-	long	l,deleted=0;
-	int32_t	msgs;
+	long	deleted=0;
+	uint32_t	u,msgs;
 	mail_t	*mail;
 	smbmsg_t msg;
 
@@ -397,12 +397,12 @@ void sbbs_t::qwk_success(ulong msgcnt, char bi, char prepack)
 		}
 
 		/* Mark as READ and DELETE */
-		for(l=0;l<msgs;l++) {
-			if(mail[l].number>qwkmail_last)
+		for(u=0;u<msgs;u++) {
+			if(mail[u].number>qwkmail_last)
 				continue;
 			memset(&msg,0,sizeof(msg));
 			/* !IMPORTANT: search by number (do not initialize msg.idx.offset) */
-			if(!loadmsg(&msg,mail[l].number))
+			if(!loadmsg(&msg,mail[u].number))
 				continue;
 			if(!(msg.hdr.attr&MSG_READ)) {
 				if(thisnode.status==NODE_INUSE)
diff --git a/src/sbbs3/qwknodes.c b/src/sbbs3/qwknodes.c
index beb74912c156b01de53755d1409a7e49f54c604c..33f66ad6bb4e98935687d2b62d2a7a783c0195b0 100644
--- a/src/sbbs3/qwknodes.c
+++ b/src/sbbs3/qwknodes.c
@@ -43,9 +43,9 @@ unsigned _stklen=10000;
 smb_t		smb;
 scfg_t		cfg;
 
-void stripctrla(uchar *str)
+void stripctrla(char *str)
 {
-	uchar out[256];
+	char out[256];
 	int i,j;
 
 	for(i=j=0;str[i] && j<sizeof(out)-1;i++) {
diff --git a/src/sbbs3/readmail.cpp b/src/sbbs3/readmail.cpp
index 930e982b35f5c8976a542e1d82f83dfca8c158ec..503eb9bca5c62e8b980e5d77a13d4912d889cc7f 100644
--- a/src/sbbs3/readmail.cpp
+++ b/src/sbbs3/readmail.cpp
@@ -45,7 +45,8 @@ void sbbs_t::readmail(uint usernumber, int which)
 	char	str[256],str2[256],str3[256],done=0,domsg=1
 			,*p,*tp,*sp,ch;
 	char 	tmp[512];
-	int		i,j;
+	int		i;
+	uint32_t u,v;
 	int		error;
 	int		mismatches=0,act;
 	uint	unum;
@@ -518,23 +519,23 @@ void sbbs_t::readmail(uint usernumber, int which)
 					bputs(text[MailOnSystemLstHdr]);
 				else
 					bputs(text[MailWaitingLstHdr]);
-				for(;i<smb.msgs && !msgabort();i++) {
+				for(;u<smb.msgs && !msgabort();u++) {
 					if(msg.total_hfields)
 						smb_freemsgmem(&msg);
 					msg.total_hfields=0;
-					msg.idx.offset=mail[i].offset;
-					if(!loadmsg(&msg,mail[i].number))
+					msg.idx.offset=mail[u].offset;
+					if(!loadmsg(&msg,mail[u].number))
 						continue;
 					smb_unlockmsghdr(&smb,&msg);
 					if(which==MAIL_ALL)
 						bprintf(text[MailOnSystemLstFmt]
-							,i+1,msg.from,msg.to
+							,u+1,msg.from,msg.to
 							,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
 								: msg.hdr.attr&MSG_READ ? ' '
 								: msg.from_net.type || msg.to_net.type ? 'N':'*'
 							,msg.subj);
 					else
-						bprintf(text[MailWaitingLstFmt],i+1
+						bprintf(text[MailWaitingLstFmt],u+1
 							,which==MAIL_SENT ? msg.to
 							: (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP
 							? text[Anonymous] : msg.from
@@ -568,11 +569,11 @@ void sbbs_t::readmail(uint usernumber, int which)
 				}
 				break;
 			case '>':
-				for(i=smb.curmsg+1;i<smb.msgs;i++)
-					if(mail[i].subj==msg.idx.subj)
+				for(u=smb.curmsg+1;u<smb.msgs;u++)
+					if(mail[u].subj==msg.idx.subj)
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				else
 					domsg=0;
 				break;
@@ -587,52 +588,62 @@ void sbbs_t::readmail(uint usernumber, int which)
 				break;
 			case '}':   /* Search Author forward */
 				strcpy(str,msg.from);
-				for(i=smb.curmsg+1;i<smb.msgs;i++)
-					if(mail[i].from==msg.idx.from)
+				for(u=smb.curmsg+1;u<smb.msgs;u++)
+					if(mail[u].from==msg.idx.from)
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				else
 					domsg=0;
 				break;
 			case 'N':   /* Got to next un-read message */
-				for(i=smb.curmsg+1;i<smb.msgs;i++)
-					if(!(mail[i].attr&MSG_READ))
+				for(u=smb.curmsg+1;u<smb.msgs;u++)
+					if(!(mail[u].attr&MSG_READ))
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				else
 					domsg=0;
 				break;
 			case '{':   /* Search Author backward */
 				strcpy(str,msg.from);
-				for(i=smb.curmsg-1;i>-1;i--)
-					if(mail[i].from==msg.idx.from)
-						break;
-				if(i>-1)
-					smb.curmsg=i;
-				else
-					domsg=0;
+				if(smb.curmsg > 0) {
+					for(u=smb.curmsg-1;;u--) {
+						if(mail[u].from==msg.idx.from) {
+							smb.curmsg=u;
+							break;
+						}
+						if(u==0) {
+							domsg=0;
+							break;
+						}
+					}
+				}
 				break;
 			case ']':   /* Search To User forward */
 				strcpy(str,msg.to);
-				for(i=smb.curmsg+1;i<smb.msgs;i++)
-					if(mail[i].to==msg.idx.to)
+				for(u=smb.curmsg+1;u<smb.msgs;u++)
+					if(mail[u].to==msg.idx.to)
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				else
 					domsg=0;
 				break;
 			case '[':   /* Search To User backward */
 				strcpy(str,msg.to);
-				for(i=smb.curmsg-1;i>-1;i--)
-					if(mail[i].to==msg.idx.to)
-						break;
-				if(i>-1)
-					smb.curmsg=i;
-				else
-					domsg=0;
+				if(smb.curmsg > 0) {
+					for(u=smb.curmsg-1;;u--) {
+						if(mail[u].to==msg.idx.to) {
+							smb.curmsg=u;
+							break;
+						}
+						if(u==0) {
+							domsg=0;
+							break;
+						}
+					}
+				}
 				break;
 			case 0:
 			case '+':
@@ -657,11 +668,11 @@ void sbbs_t::readmail(uint usernumber, int which)
 				break;
 			case 'T':
 				domsg=0;
-				i=smb.curmsg;
-				if(i) i++;
-				j=i+10;
-				if(j>smb.msgs)
-					j=smb.msgs;
+				u=smb.curmsg;
+				if(u) u++;
+				v=u+10;
+				if(v>smb.msgs)
+					v=smb.msgs;
 
 				if(which==MAIL_SENT)
 					bputs(text[MailSentLstHdr]);
@@ -669,23 +680,23 @@ void sbbs_t::readmail(uint usernumber, int which)
 					bputs(text[MailOnSystemLstHdr]);
 				else
 					bputs(text[MailWaitingLstHdr]);
-				for(;i<j;i++) {
+				for(;u<v;u++) {
 					if(msg.total_hfields)
 						smb_freemsgmem(&msg);
 					msg.total_hfields=0;
-					msg.idx.offset=mail[i].offset;
-					if(!loadmsg(&msg,mail[i].number))
+					msg.idx.offset=mail[u].offset;
+					if(!loadmsg(&msg,mail[u].number))
 						continue;
 					smb_unlockmsghdr(&smb,&msg);
 					if(which==MAIL_ALL)
 						bprintf(text[MailOnSystemLstFmt]
-							,i+1,msg.from,msg.to
+							,u+1,msg.from,msg.to
 							,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
 								: msg.hdr.attr&MSG_READ ? ' ' 
 								: msg.from_net.type || msg.to_net.type ? 'N':'*'
 							,msg.subj);
 					else
-						bprintf(text[MailWaitingLstFmt],i+1
+						bprintf(text[MailWaitingLstFmt],u+1
 							,which==MAIL_SENT ? msg.to
 							: (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP
 							? text[Anonymous] : msg.from
@@ -696,7 +707,7 @@ void sbbs_t::readmail(uint usernumber, int which)
 					smb_freemsgmem(&msg);
 					msg.total_hfields=0; 
 				}
-				smb.curmsg=(i-1);
+				smb.curmsg=(u-1);
 				break;
 			case 'U':   /* user edit */
 				msg.hdr.number=msg.idx.number;
diff --git a/src/sbbs3/readmsgs.cpp b/src/sbbs3/readmsgs.cpp
index a82cad3437acd00009c1a7622d2d3218582d3cb5..a85c7c55376d2aa9975ba4336fcbc151e7bb505e 100644
--- a/src/sbbs3/readmsgs.cpp
+++ b/src/sbbs3/readmsgs.cpp
@@ -175,7 +175,7 @@ void sbbs_t::msghdr(smbmsg_t* msg)
 
 /****************************************************************************/
 /****************************************************************************/
-post_t * sbbs_t::loadposts(int32_t *posts, uint subnum, ulong ptr, long mode, ulong *unvalidated_num)
+post_t * sbbs_t::loadposts(uint32_t *posts, uint subnum, ulong ptr, long mode, ulong *unvalidated_num)
 {
 	char name[128];
 	ushort aliascrc,namecrc,sysop;
@@ -332,9 +332,9 @@ post_t * sbbs_t::loadposts(int32_t *posts, uint subnum, ulong ptr, long mode, ul
 	return(post);
 }
 
-static int get_start_msg(sbbs_t* sbbs, smb_t* smb)
+static uint32_t get_start_msg(sbbs_t* sbbs, smb_t* smb)
 {
-	int i,j=smb->curmsg+1;
+	uint32_t	i,j=smb->curmsg+1;
 
 	if(j<smb->msgs)
 		j++;
@@ -368,6 +368,7 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 	long	org_mode=mode;
 	ulong	msgs,l,unvalidated;
 	uint32_t last;
+	uint32_t u;
 	post_t	*post;
 	smbmsg_t	msg;
 
@@ -941,11 +942,11 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 					 done=1;
 					 break; 
 				}
-				i=smb.curmsg+11;
-				if(i>smb.msgs)
-					i=smb.msgs;
-				listmsgs(subnum,0,post,smb.curmsg+1,i);
-				smb.curmsg=i-1;
+				u=smb.curmsg+11;
+				if(u>smb.msgs)
+					u=smb.msgs;
+				listmsgs(subnum,0,post,smb.curmsg+1,u);
+				smb.curmsg=u-1;
 				if(subscan[subnum].ptr<post[smb.curmsg].number)
 					subscan[subnum].ptr=post[smb.curmsg].number;
 				break;
@@ -1072,11 +1073,11 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 					domsg=0;
 					break; 
 				}
-				for(i=0;i<smb.msgs;i++)
-					if(l==post[i].number)
+				for(u=0;u<smb.msgs;u++)
+					if(l==post[u].number)
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				do_find=false;
 				break;
 			case ',':   /* Thread backwards */
@@ -1084,19 +1085,19 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 					domsg=0;
 					break; 
 				}
-				for(i=0;i<smb.msgs;i++)
-					if(msg.hdr.thread_back==post[i].number)
+				for(u=0;u<smb.msgs;u++)
+					if(msg.hdr.thread_back==post[u].number)
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				do_find=false;
 				break;
 			case '>':   /* Search Title forward */
-				for(i=smb.curmsg+1;i<smb.msgs;i++)
-					if(post[i].subj==msg.idx.subj)
+				for(u=smb.curmsg+1;u<smb.msgs;u++)
+					if(post[u].subj==msg.idx.subj)
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				else
 					domsg=0;
 				do_find=false;
@@ -1113,11 +1114,11 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 				break;
 			case '}':   /* Search Author forward */
 				strcpy(str,msg.from);
-				for(i=smb.curmsg+1;i<smb.msgs;i++)
-					if(post[i].from==msg.idx.from)
+				for(u=smb.curmsg+1;u<smb.msgs;u++)
+					if(post[u].from==msg.idx.from)
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				else
 					domsg=0;
 				do_find=false;
@@ -1135,11 +1136,11 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 				break;
 			case ']':   /* Search To User forward */
 				strcpy(str,msg.to);
-				for(i=smb.curmsg+1;i<smb.msgs;i++)
-					if(post[i].to==msg.idx.to)
+				for(u=smb.curmsg+1;u<smb.msgs;u++)
+					if(post[u].to==msg.idx.to)
 						break;
-				if(i<smb.msgs)
-					smb.curmsg=i;
+				if(u<smb.msgs)
+					smb.curmsg=u;
 				else
 					domsg=0;
 				do_find=false;
@@ -1194,7 +1195,7 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
 long sbbs_t::listsub(uint subnum, long mode, long start, const char* search)
 {
 	int 	i;
-	int32_t	posts;
+	uint32_t	posts;
 	long	displayed;
 	post_t	*post;
 
diff --git a/src/sbbs3/rechocfg.c b/src/sbbs3/rechocfg.c
index f0869ec1779f3c5767bb52cbf57b39942e353d26..524686470e0c454e0eb883941dc3afa58576230b 100644
--- a/src/sbbs3/rechocfg.c
+++ b/src/sbbs3/rechocfg.c
@@ -176,9 +176,11 @@ int matchnode(faddr_t addr, int exact)
 	return(i);
 }
 
+#define SKIPCTRLSP(p)	while(*p>0 && *p<=' ') p++
+#define SKIPCODE(p)		while(*p<0 || *p>' ') p++
 void read_echo_cfg()
 {
-	uchar str[1025],tmp[512],*p,*tp;
+	char str[1025],tmp[512],*p,*tp;
 	short attr=0;
 	int i,j,file;
 	FILE *stream;
@@ -204,7 +206,7 @@ void read_echo_cfg()
 			break;
 		truncsp(str);
 		p=str;
-		while(*p && *p<=' ') p++;
+		SKIPCTRLSP(p);
 		if(*p==';')
 			continue;
 		sprintf(tmp,"%-.25s",p);
@@ -214,8 +216,8 @@ void read_echo_cfg()
 #if 0
 		strupr(tmp);                            /* Convert code to uppercase */
 #endif
-		while(*p>' ') p++;                       /* Skip code */
-		while(*p && *p<=' ') p++;                /* Skip white space */
+		SKIPCODE(p);                       /* Skip code */
+		SKIPCTRLSP(p);                /* Skip white space */
 
 		if(!stricmp(tmp,"PACKER")) {             /* Archive Definition */
 			if((cfg.arcdef=(arcdef_t *)realloc(cfg.arcdef
@@ -227,27 +229,27 @@ void read_echo_cfg()
 			tp=cfg.arcdef[cfg.arcdefs].name;
 			while(*tp && *tp>' ') tp++;
 			*tp=0;
-			while(*p && *p>' ') p++;
-			while(*p && *p<=' ') p++;
+			SKIPCODE(p);
+			SKIPCTRLSP(p);
 			cfg.arcdef[cfg.arcdefs].byteloc=atoi(p);
-			while(*p && *p>' ') p++;
-			while(*p && *p<=' ') p++;
+			SKIPCODE(p);
+			SKIPCTRLSP(p);
 			SAFECOPY(cfg.arcdef[cfg.arcdefs].hexid,p);
 			tp=cfg.arcdef[cfg.arcdefs].hexid;
-			while(*tp && *tp>' ') tp++;
+			SKIPCODE(tp);
 			*tp=0;
 			while(fgets(str,256,stream) && strnicmp(str,"END",3)) {
 				p=str;
-				while(*p && *p<=' ') p++;
+				SKIPCTRLSP(p);
 				if(!strnicmp(p,"PACK ",5)) {
 					p+=5;
-					while(*p && *p<=' ') p++;
+					SKIPCTRLSP(p);
 					SAFECOPY(cfg.arcdef[cfg.arcdefs].pack,p);
 					truncsp(cfg.arcdef[cfg.arcdefs].pack);
 					continue; }
 				if(!strnicmp(p,"UNPACK ",7)) {
 					p+=7;
-					while(*p && *p<=' ') p++;
+					SKIPCTRLSP(p);
 					SAFECOPY(cfg.arcdef[cfg.arcdefs].unpack,p);
 					truncsp(cfg.arcdef[cfg.arcdefs].unpack); } }
 			++cfg.arcdefs;
@@ -365,7 +367,7 @@ void read_echo_cfg()
 				continue;
 			SAFECOPY(str,p);
 			p=str;
-			while(*p && *p>' ') p++;
+			SKIPCODE(p);
 			if(!*p)
 				continue;
 			*p=0;
@@ -377,11 +379,11 @@ void read_echo_cfg()
 			if(i==cfg.arcdefs)				/* i = number of arcdef til done */
 				i=0xffff;					/* Uncompressed type if not found */
 			while(*p) {
-				while(*p && *p<=' ') p++;
+				SKIPCTRLSP(p);
 				if(!*p)
 					break;
 				addr=atofaddr(p);
-				while(*p && *p>' ') p++;
+				SKIPCODE(p);
 				j=matchnode(addr,1);
 				if(j==cfg.nodecfgs) {
 					cfg.nodecfgs++;
@@ -398,8 +400,8 @@ void read_echo_cfg()
 			if(!*p)
 				continue;
 			addr=atofaddr(p);
-			while(*p && *p>' ') p++;         /* Skip address */
-			while(*p && *p<=' ') p++;        /* Find beginning of password */
+			SKIPCODE(p);         /* Skip address */
+			SKIPCTRLSP(p);        /* Find beginning of password */
 			j=matchnode(addr,1);
 			if(j==cfg.nodecfgs) {
 				cfg.nodecfgs++;
@@ -417,15 +419,15 @@ void read_echo_cfg()
 				continue;
 			SAFECOPY(str,p);
 			p=str;
-			while(*p && *p>' ') p++;
+			SKIPCODE(p);
 			*p=0;
 			p++;
 			while(*p) {
-				while(*p && *p<=' ') p++;
+				SKIPCTRLSP(p);
 				if(!*p)
 					break;
 				addr=atofaddr(p);
-				while(*p && *p>' ') p++;
+				SKIPCODE(p);
 				j=matchnode(addr,1);
 				if(j==cfg.nodecfgs) {
 					cfg.nodecfgs++;
@@ -445,11 +447,11 @@ void read_echo_cfg()
 
 		if(!stricmp(tmp,"SEND_NOTIFY")) {    /* Nodes to send notify lists to */
 			while(*p) {
-				while(*p && *p<=' ') p++;
+				SKIPCTRLSP(p);
 				if(!*p)
 					break;
 				addr=atofaddr(p);
-				while(*p && *p>' ') p++;
+				SKIPCODE(p);
 				j=matchnode(addr,1);
 				if(j==cfg.nodecfgs) {
 					cfg.nodecfgs++;
@@ -475,11 +477,11 @@ void read_echo_cfg()
 			else if(!stricmp(tmp,"DIRECT"))
 				attr=ATTR_DIRECT;
 			while(*p) {
-				while(*p && *p<=' ') p++;
+				SKIPCTRLSP(p);
 				if(!*p)
 					break;
 				addr=atofaddr(p);
-				while(*p && *p>' ') p++;
+				SKIPCODE(p);
 				j=matchnode(addr,1);
 				if(j==cfg.nodecfgs) {
 					cfg.nodecfgs++;
@@ -493,16 +495,16 @@ void read_echo_cfg()
 				cfg.nodecfg[j].attr|=attr; } }
 
 		if(!stricmp(tmp,"ROUTE_TO")) {
-			while(*p && *p<=' ') p++;
+			SKIPCTRLSP(p);
 			if(*p) {
 				route_addr=atofaddr(p);
-				while(*p && *p>' ') p++; }
+				SKIPCODE(p); }
 			while(*p) {
-				while(*p && *p<=' ') p++;
+				SKIPCTRLSP(p);
 				if(!*p)
 					break;
 				addr=atofaddr(p);
-				while(*p && *p>' ') p++;
+				SKIPCODE(p);
 				j=matchnode(addr,1);
 				if(j==cfg.nodecfgs) {
 					cfg.nodecfgs++;
@@ -530,19 +532,19 @@ void read_echo_cfg()
 				memset(&cfg.nodecfg[i],0,sizeof(nodecfg_t));
 				cfg.nodecfg[i].faddr=addr; }
 			cfg.nodecfg[i].flag=NULL;
-			while(*p && *p>' ') p++; 		/* Get to the end of the address */
-			while(*p && *p<=' ') p++;		/* Skip over whitespace chars */
+			SKIPCODE(p); 		/* Get to the end of the address */
+			SKIPCTRLSP(p);		/* Skip over whitespace chars */
 			tp=p;
-			while(*p && *p>' ') p++; 		/* Find end of password 	*/
+			SKIPCODE(p); 		/* Find end of password 	*/
 			*p=0;							/* and terminate the string */
 			++p;
 			SAFECOPY(cfg.nodecfg[i].password,tp);
-			while(*p && *p<=' ') p++;		/* Search for more chars */
+			SKIPCTRLSP(p);		/* Search for more chars */
 			if(!*p) 						/* Nothing else there */
 				continue;
 			while(*p) {
 				tp=p;
-				while(*p && *p>' ') p++; 	/* Find end of this flag */
+				SKIPCODE(p); 	/* Find end of this flag */
 				*p=0;						/* and terminate it 	 */
 				++p;
 				for(j=0;j<cfg.nodecfg[i].numflags;j++)
@@ -558,7 +560,7 @@ void read_echo_cfg()
 						bail(1); }
 					cfg.nodecfg[i].numflags++;
 					SAFECOPY(cfg.nodecfg[i].flag[j].flag,tp); }
-				while(*p && *p<=' ') p++; } }
+				SKIPCTRLSP(p); } }
 
 		if(!stricmp(tmp,"ECHOLIST")) {           /* Echolists go here */
 			if((cfg.listcfg=(echolist_t *)realloc(cfg.listcfg
@@ -572,35 +574,35 @@ void read_echo_cfg()
 			if(!strnicmp(p,"FORWARD ",8) || !strnicmp(p,"HUB ",4)) {
 				if(!strnicmp(p,"HUB ",4))
 					cfg.listcfg[cfg.listcfgs-1].misc|=NOFWD;
-				while(*p && *p>' ') p++;
-				while(*p && *p<=' ') p++;
+				SKIPCODE(p);
+				SKIPCTRLSP(p);
 				if(*p)
 					cfg.listcfg[cfg.listcfgs-1].forward=atofaddr(p);
-				while(*p && *p>' ') p++;
-				while(*p && *p<=' ') p++;
+				SKIPCODE(p);
+				SKIPCTRLSP(p);
 				if(*p && !(cfg.listcfg[cfg.listcfgs-1].misc&NOFWD)) {
 					tp=p;
-					while(*p && *p>' ') p++;
+					SKIPCODE(p);
 					*p=0;
 					++p;
-					while(*p && *p<=' ') p++;
+					SKIPCTRLSP(p);
 					SAFECOPY(cfg.listcfg[cfg.listcfgs-1].password,tp); } }
 			else
 				cfg.listcfg[cfg.listcfgs-1].misc|=NOFWD;
 			if(!*p)
 				continue;
 			tp=p;
-			while(*p && *p>' ') p++;
+			SKIPCODE(p);
 			*p=0;
 			p++;
 
 			SAFECOPY(cfg.listcfg[cfg.listcfgs-1].listpath,tp);
 			cfg.listcfg[cfg.listcfgs-1].numflags=0;
 			cfg.listcfg[cfg.listcfgs-1].flag=NULL;
-			while(*p && *p<=' ') p++;		/* Skip over whitespace chars */
+			SKIPCTRLSP(p);		/* Skip over whitespace chars */
 			while(*p) {
 				tp=p;
-				while(*p && *p>' ') p++; 	/* Find end of this flag */
+				SKIPCODE(p); 	/* Find end of this flag */
 				*p=0;						/* and terminate it 	 */
 				++p;
 				for(j=0;j<cfg.listcfg[cfg.listcfgs-1].numflags;j++)
@@ -616,7 +618,7 @@ void read_echo_cfg()
 						bail(1); }
 					cfg.listcfg[cfg.listcfgs-1].numflags++;
 					SAFECOPY(cfg.listcfg[cfg.listcfgs-1].flag[j].flag,tp); }
-				while(*p && *p<=' ') p++; } }
+				SKIPCTRLSP(p); } }
 
 		/* Message disabled why?  ToDo */
 		/* printf("Unrecognized line in SBBSECHO.CFG file.\n"); */
diff --git a/src/sbbs3/ringbuf.c b/src/sbbs3/ringbuf.c
index edd333ad80aba219211575533911326c92fa0866..cbac1d22a07f1560060060f46f2fb8913efdaca2 100644
--- a/src/sbbs3/ringbuf.c
+++ b/src/sbbs3/ringbuf.c
@@ -163,7 +163,7 @@ DWORD RINGBUFCALL RingBufFree( RingBuf* rb )
 	return(retval);
 }
 
-DWORD RINGBUFCALL RingBufWrite( RingBuf* rb, BYTE* src,  DWORD cnt )
+DWORD RINGBUFCALL RingBufWrite( RingBuf* rb, const BYTE* src,  DWORD cnt )
 {
 	DWORD max, first, remain;
 
diff --git a/src/sbbs3/ringbuf.h b/src/sbbs3/ringbuf.h
index de431ad37c86dc3b79cc820a85bd4347dfc7f06f..9d9454a8ea0a75228028f22ebb486a8d25acf774 100644
--- a/src/sbbs3/ringbuf.h
+++ b/src/sbbs3/ringbuf.h
@@ -110,7 +110,7 @@ int 	RINGBUFCALL RingBufInit( RingBuf* rb, DWORD size
 void	RINGBUFCALL RingBufDispose( RingBuf* rb );
 DWORD	RINGBUFCALL RingBufFull( RingBuf* rb );
 DWORD	RINGBUFCALL RingBufFree( RingBuf* rb );
-DWORD	RINGBUFCALL RingBufWrite( RingBuf* rb, BYTE *src,	DWORD cnt );
+DWORD	RINGBUFCALL RingBufWrite( RingBuf* rb, const BYTE *src,	DWORD cnt );
 DWORD	RINGBUFCALL RingBufRead( RingBuf* rb, BYTE *dst,  DWORD cnt );
 DWORD	RINGBUFCALL RingBufPeek( RingBuf* rb, BYTE *dst,  DWORD cnt );
 void	RINGBUFCALL RingBufReInit( RingBuf* rb );
diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h
index d9d5d8ca06c3103b4ce57422e6f3b461ab10517a..cda7189d51bee2d475a63653dfe26f8870154fc1 100644
--- a/src/sbbs3/sbbs.h
+++ b/src/sbbs3/sbbs.h
@@ -499,7 +499,7 @@ public:
 
 	/* writemsg.cpp */
 	void	automsg(void);
-	bool	writemsg(const char *str, const char *top, char *title, long mode, int subnum
+	bool	writemsg(const char *str, const char *top, char *title, long mode, uint subnum
 				,const char *dest, char** editor=NULL);
 	char*	quotes_fname(int xedit, char* buf, size_t len);
 	char*	msg_tmp_fname(int xedit, char* fname, size_t len);
@@ -534,7 +534,7 @@ public:
 	void	delallmail(uint usernumber, int which, bool permanent=true);
 
 	/* getmsg.cpp */
-	post_t* loadposts(int32_t *posts, uint subnum, ulong ptr, long mode, ulong *unvalidated_num);
+	post_t* loadposts(uint32_t *posts, uint subnum, ulong ptr, long mode, ulong *unvalidated_num);
 
 	/* readmail.cpp */
 	void	readmail(uint usernumber, int sent);
@@ -782,7 +782,7 @@ public:
 	uint	resolve_qwkconf(uint n);
 
 	/* msgtoqwk.cpp */
-	ulong	msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, int subnum, int conf, FILE* hdrs_dat);
+	ulong	msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, uint subnum, int conf, FILE* hdrs_dat);
 
 	/* qwktomsg.cpp */
 	void	qwk_new_msg(smbmsg_t* msg, char* hdrblk, long offset, str_list_t headers, bool parse_sender_hfields);
@@ -871,7 +871,7 @@ extern "C" {
 
 	/* getmail.c */
 	DLLEXPORT int		DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent);
-	DLLEXPORT mail_t *	DLLCALL loadmail(smb_t* smb, int32_t* msgs, uint usernumber
+	DLLEXPORT mail_t *	DLLCALL loadmail(smb_t* smb, uint32_t* msgs, uint usernumber
 										,int which, long mode);
 	DLLEXPORT void		DLLCALL freemail(mail_t* mail);
 	DLLEXPORT void		DLLCALL delfattach(scfg_t*, smbmsg_t*);
diff --git a/src/sbbs3/sbbsecho.c b/src/sbbs3/sbbsecho.c
index 955ee1680942dad1f90554e539f656bbb090693c..0a864269390e93dd939b8317ee6e0bdb595f9f0d 100644
--- a/src/sbbs3/sbbsecho.c
+++ b/src/sbbs3/sbbsecho.c
@@ -1366,7 +1366,7 @@ char* process_areafix(faddr_t addr, char* inbuf, char* password, char* to)
 	del_area.tags=0;
 	del_area.tag=NULL;
 	for(l=0;l<m;l++) { 
-		while(*(p+l) && isspace(*(p+l))) l++;
+		while(*(p+l) && isspace((uchar)*(p+l))) l++;
 		while(*(p+l)==CTRL_A) {				/* Ignore kludge lines June-13-2004 */
 			while(*(p+l) && *(p+l)!='\r') l++;
 			continue;
@@ -2113,7 +2113,7 @@ time_t fmsgtime(char *str)
 	memset(&tm,0,sizeof(tm));
 	tm.tm_isdst=-1;	/* Do not adjust for DST */
 
-	if(isdigit(str[1])) {	/* Regular format: "01 Jan 86  02:34:56" */
+	if(isdigit((uchar)str[1])) {	/* Regular format: "01 Jan 86  02:34:56" */
 		tm.tm_mday=atoi(str);
 		sprintf(month,"%3.3s",str+3);
 		if(!stricmp(month,"jan"))
@@ -2195,9 +2195,9 @@ static short fmsgzone(char* p)
 	else
 		west=FALSE;
 
-	if(strlen(p)>=2)
+	if(strlen((char*)p)>=2)
 		sprintf(hr,"%.2s",p);
-	if(strlen(p+2)>=2)
+	if(strlen((char*)p+2)>=2)
 		sprintf(min,"%.2s",p+2);
 
 	val=atoi(hr)*60;
@@ -2224,7 +2224,7 @@ static short fmsgzone(char* p)
 
 char* getfmsg(FILE *stream, ulong *outlen)
 {
-	uchar* fbuf;
+	char* fbuf;
 	int ch;
 	ulong l,length,start;
 
@@ -2264,11 +2264,10 @@ char* getfmsg(FILE *stream, ulong *outlen)
 /* Coverts a FidoNet message into a Synchronet message						*/
 /* Returns 0 on success, 1 dupe, 2 filtered, 3 empty, or other SMB error	*/
 /****************************************************************************/
-int fmsgtosmsg(uchar* fbuf, fmsghdr_t fmsghdr, uint user, uint subnum)
+int fmsgtosmsg(char* fbuf, fmsghdr_t fmsghdr, uint user, uint subnum)
 {
-	uchar	ch,*sbody,stail[MAX_TAILLEN+1]
-				,*p,str[128];
-	char	msg_id[256];
+	uchar	ch,stail[MAX_TAILLEN+1],*sbody;
+	char	msg_id[256],str[128],*p;
 	BOOL	done,esc,cr;
 	int 	i,storage=SMB_SELFPACK;
 	uint	col;
@@ -2327,7 +2326,7 @@ int fmsgtosmsg(uchar* fbuf, fmsghdr_t fmsghdr, uint user, uint subnum)
 		return(-1); 
 	}
 	length=strlen((char *)fbuf);
-	if((sbody=(char*)malloc((length+1)*2))==NULL) {
+	if((sbody=(uchar*)malloc((length+1)*2))==NULL) {
 		lprintf(LOG_ERR,"ERROR line %d allocating %lu bytes for body",__LINE__
 			,(length+1)*2L);
 		smb_freemsgmem(&msg);
@@ -2339,10 +2338,10 @@ int fmsgtosmsg(uchar* fbuf, fmsghdr_t fmsghdr, uint user, uint subnum)
 		if(!l && !strncmp((char *)fbuf,"AREA:",5)) {
 			save=l;
 			l+=5;
-			while(l<length && fbuf[l]<=' ') l++;
+			while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 			m=l;
 			while(m<length && fbuf[m]!='\r') m++;
-			while(m && fbuf[m-1]<=' ') m--;
+			while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 			if(m>l)
 				smb_hfield(&msg,FIDOAREA,(ushort)(m-l),fbuf+l);
 			while(l<length && fbuf[l]!='\r') l++;
@@ -2376,76 +2375,76 @@ int fmsgtosmsg(uchar* fbuf, fmsghdr_t fmsghdr, uint user, uint subnum)
 
 			else if(!strncmp((char *)fbuf+l+1,"MSGID:",6)) {
 				l+=7;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
 				while(m<length && fbuf[m]!='\r') m++;
-				while(m && fbuf[m-1]<=' ') m--;
+				while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 				if(m>l)
 					smb_hfield(&msg,FIDOMSGID,(ushort)(m-l),fbuf+l); }
 
 			else if(!strncmp((char *)fbuf+l+1,"REPLY:",6)) {
 				l+=7;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
 				while(m<length && fbuf[m]!='\r') m++;
-				while(m && fbuf[m-1]<=' ') m--;
+				while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 				if(m>l)
 					smb_hfield(&msg,FIDOREPLYID,(ushort)(m-l),fbuf+l); }
 
 			else if(!strncmp((char *)fbuf+l+1,"FLAGS ",6)		/* correct */
 				||  !strncmp((char *)fbuf+l+1,"FLAGS:",6)) {	/* incorrect */
 				l+=7;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
 				while(m<length && fbuf[m]!='\r') m++;
-				while(m && fbuf[m-1]<=' ') m--;
+				while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 				if(m>l)
 					smb_hfield(&msg,FIDOFLAGS,(ushort)(m-l),fbuf+l); }
 
 			else if(!strncmp((char *)fbuf+l+1,"PATH:",5)) {
 				l+=6;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
 				while(m<length && fbuf[m]!='\r') m++;
-				while(m && fbuf[m-1]<=' ') m--;
+				while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 				if(m>l && (misc&STORE_PATH))
 					smb_hfield(&msg,FIDOPATH,(ushort)(m-l),fbuf+l); }
 
 			else if(!strncmp((char *)fbuf+l+1,"PID:",4)) {
 				l+=5;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
 				while(m<length && fbuf[m]!='\r') m++;
-				while(m && fbuf[m-1]<=' ') m--;
+				while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 				if(m>l)
 					smb_hfield(&msg,FIDOPID,(ushort)(m-l),fbuf+l); }
 
 			else if(!strncmp((char *)fbuf+l+1,"TID:",4)) {
 				l+=5;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
 				while(m<length && fbuf[m]!='\r') m++;
-				while(m && fbuf[m-1]<=' ') m--;
+				while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 				if(m>l)
 					smb_hfield(&msg,FIDOTID,(ushort)(m-l),fbuf+l); }
 
 			else if(!strncmp((char *)fbuf+l+1,"TZUTC:",6)) {		/* FSP-1001 */
 				l+=7;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				msg.hdr.when_written.zone = fmsgzone(fbuf+l);
 			}
 
 			else if(!strncmp((char *)fbuf+l+1,"TZUTCINFO:",10)) {	/* non-standard */
 				l+=11;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				msg.hdr.when_written.zone = fmsgzone(fbuf+l);
 			}
 
 			else {		/* Unknown kludge line */
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
 				while(m<length && fbuf[m]!='\r') m++;
-				while(m && fbuf[m-1]<=' ') m--;
+				while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 				if(m>l && (misc&STORE_KLUDGE))
 					smb_hfield(&msg,FIDOCTRL,(ushort)(m-l),fbuf+l); }
 
@@ -2458,10 +2457,10 @@ int fmsgtosmsg(uchar* fbuf, fmsghdr_t fmsghdr, uint user, uint subnum)
 				done=1; 			/* tear line and down go into tail */
 			if(done && cr && !strncmp((char *)fbuf+l,"SEEN-BY:",8)) {
 				l+=8;
-				while(l<length && fbuf[l]<=' ') l++;
+				while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
 				m=l;
 				while(m<length && fbuf[m]!='\r') m++;
-				while(m && fbuf[m-1]<=' ') m--;
+				while(m && fbuf[m-1]<=' ' && fbuf[m-1]>=0) m--;
 				if(m>l && (misc&STORE_SEENBY))
 					smb_hfield(&msg,FIDOSEENBY,(ushort)(m-l),fbuf+l);
 				while(l<length && fbuf[l]!='\r') l++;
@@ -2483,7 +2482,7 @@ int fmsgtosmsg(uchar* fbuf, fmsghdr_t fmsghdr, uint user, uint subnum)
 			else {
 				cr=0;
 				if(col==1 && !strncmp((char *)fbuf+l," * Origin: ",11)) {
-					p=(char *)fbuf+l+11;
+					p=(char*)fbuf+l+11;
 					while(*p && *p!='\r') p++;	 /* Find CR */
 					while(p && *p!='(') p--;     /* rewind to '(' */
 					if(p)
@@ -2495,7 +2494,7 @@ int fmsgtosmsg(uchar* fbuf, fmsghdr_t fmsghdr, uint user, uint subnum)
 				if(ch==ESC) esc=1;		/* ANSI codes */
 				if(ch==' ' && col>40 && !esc) {	/* word wrap */
 					for(m=l+1;m<length;m++) 	/* find next space */
-						if(fbuf[m]<=' ')
+						if(fbuf[m]<=' ' && fbuf[m]>=0)
 							break;
 					if(m<length && m-l>80-col) {  /* if it's beyond the eol */
 						sbody[bodylen++]='\r';
@@ -2656,7 +2655,7 @@ char *pktname(BOOL temp)
  This function puts a message into a Fido packet, writing both the header
  information and the message body
 ******************************************************************************/
-void putfmsg(FILE *stream,uchar *fbuf,fmsghdr_t fmsghdr,areasbbs_t area
+void putfmsg(FILE *stream,char *fbuf,fmsghdr_t fmsghdr,areasbbs_t area
 	,addrlist_t seenbys,addrlist_t paths)
 {
 	char str[256],seenby[256];
@@ -3091,7 +3090,7 @@ void attach_bundles(void)
  parameter to 1 to force all the remaining packets closed and stuff them into
  a bundle.
 ******************************************************************************/
-void pkt_to_pkt(uchar *fbuf,areasbbs_t area,faddr_t faddr
+void pkt_to_pkt(char *fbuf,areasbbs_t area,faddr_t faddr
 	,fmsghdr_t fmsghdr,addrlist_t seenbys,addrlist_t paths, int cleanup)
 {
 	int i,j,k,file;
@@ -3291,7 +3290,7 @@ void pkt_to_pkt(uchar *fbuf,areasbbs_t area,faddr_t faddr
 int pkt_to_msg(FILE* fidomsg, fmsghdr_t* hdr, char* info)
 {
 	char path[MAX_PATH+1];
-	uchar* fmsgbuf;
+	char* fmsgbuf;
 	int i,file;
 	ulong l;
 
@@ -3334,7 +3333,7 @@ int pkt_to_msg(FILE* fidomsg, fmsghdr_t* hdr, char* info)
 /**************************************/
 int import_netmail(char *path,fmsghdr_t hdr, FILE *fidomsg)
 {
-	uchar info[512],str[256],tmp[256],subj[256]
+	char info[512],str[256],tmp[256],subj[256]
 		,*fmsgbuf=NULL,*p,*tp,*sp;
 	int i,match,usernumber;
 	ulong length;
@@ -3610,10 +3609,10 @@ void export_echomail(char *sub_code,faddr_t addr)
 	char	msgid[256];
 	char*	buf=NULL;
 	char*	minus;
-	uchar*	fmsgbuf=NULL;
+	char*	fmsgbuf=NULL;
 	ulong	fmsgbuflen;
 	int		tzone;
-	int		g,i,j,k=0,file;
+	int		g,i,j,k=0;
 	ulong	f,l,m,exp,exported=0;
 	uint32_t ptr,msgs,lastmsg,posts;
 	float	export_time;
@@ -3692,7 +3691,7 @@ void export_echomail(char *sub_code,faddr_t addr)
 				start_tick=msclock();
 
 				for(m=exp=0;m<posts;m++) {
-					printf("\r%8s %5lu of %-5lu  "
+					printf("\r%8s %5lu of %-5"PRIu32"  "
 						,scfg.sub[i]->code,m+1,posts);
 					memset(&msg,0,sizeof(msg));
 					msg.idx=post[m];
@@ -3852,7 +3851,7 @@ void export_echomail(char *sub_code,faddr_t addr)
 						else
 							cr=0;
 						if((scfg.sub[i]->misc&SUB_ASCII) || (misc&ASCII_ONLY)) {
-							if(buf[l]<' ' && buf[l]!='\r'
+							if(buf[l]<' ' && buf[l]>=0 && buf[l]!='\r'
 								&& buf[l]!='\n')			/* Ctrl ascii */
 								buf[l]='.';             /* converted to '.' */
 							if((uchar)buf[l]&0x80)		/* extended ASCII */
@@ -3953,12 +3952,12 @@ int main(int argc, char **argv)
 			,*p,*tp
 			,areatagstr[128],outbound[128]
 			,password[16];
-	uchar	*fmsgbuf=NULL;
+	char	*fmsgbuf=NULL;
 	ushort	attr;
 	int 	i,j,k,file,fmsg,grp,node;
 	BOOL	grunged;
 	uint	subnum[MAX_OPEN_SMBS]={INVALID_SUB};
-	ulong	echomail=0,l,m/* f, */,areatag;
+	ulong	echomail=0,m/* f, */,areatag;
 	time_t	now;
 	time_t	ftime;
 	float	import_time;
@@ -4130,7 +4129,7 @@ int main(int argc, char **argv)
 			if(strchr(argv[i],'\\') || strchr(argv[i],'/') 
 				|| argv[i][1]==':' || strchr(argv[i],'.'))
 				SAFECOPY(cfg.cfgfile,argv[i]);
-			else if(isdigit(argv[i][0]))
+			else if(isdigit((uchar)argv[i][0]))
 				addr=atofaddr(argv[i]);
 			else
 				SAFECOPY(sub_code,argv[i]); 
diff --git a/src/sbbs3/sbbsecho.h b/src/sbbs3/sbbsecho.h
index 567a35db471f6ca599346c8cde2dd0c5eb12e93a..69f123f75e94ecd911a26095a374738467166bc9 100644
--- a/src/sbbs3/sbbsecho.h
+++ b/src/sbbs3/sbbsecho.h
@@ -140,9 +140,9 @@ typedef struct {						/* Type 2+ Packet Header Info */
 	} two_plus_t;
 
 typedef struct {						/* Type 2.2 Packet Header Info */
-	uchar origdomn[8],					/* Origination Domain */
-		  destdomn[8],					/* Destination Domain */
-		  empty[4]; 					/* Product Specific Data */
+	char origdomn[8],					/* Origination Domain */
+		  destdomn[8];					/* Destination Domain */
+	uchar	  empty[4]; 					/* Product Specific Data */
 	} two_two_t;
 
 typedef struct {
@@ -169,7 +169,7 @@ typedef struct {
 typedef struct {
 	FILE *stream;				/* The stream associated with this packet (NULL if not-open) */
 	faddr_t uplink; 			/* The current uplink for this packet */
-	uchar filename[MAX_PATH+1];	/* Name of the file */
+	char filename[MAX_PATH+1];	/* Name of the file */
     } outpkt_t;
 
 typedef struct {
diff --git a/src/sbbs3/scfgsave.c b/src/sbbs3/scfgsave.c
index 3d9b66f15cbaf7816eccf7a9bdd09aabddd2ab2a..ff9e9ddaf3de5b2606c011765b843f7228c6c38c 100644
--- a/src/sbbs3/scfgsave.c
+++ b/src/sbbs3/scfgsave.c
@@ -1036,7 +1036,8 @@ BOOL DLLCALL write_chat_cfg(scfg_t* cfg, int backup_level)
 /****************************************************************************/
 BOOL DLLCALL write_xtrn_cfg(scfg_t* cfg, int backup_level)
 {
-	uchar	str[MAX_PATH+1],c;
+	char	str[MAX_PATH+1];
+	uchar	c;
 	int 	i,j,sec,file;
 	uint16_t	n;
 	FILE	*stream;
diff --git a/src/sbbs3/services.c b/src/sbbs3/services.c
index 738757a47d5ae25fdc1bcf98c5cd4176f1c6fb45..419e19d7c4f4b47c52008a7f750dc0657720889e 100644
--- a/src/sbbs3/services.c
+++ b/src/sbbs3/services.c
@@ -1164,7 +1164,7 @@ static void js_service_thread(void* arg)
 	if(service->options&SERVICE_OPT_UDP 
 		&& service_client.udp_buf != NULL
 		&& service_client.udp_len > 0) {
-		datagram = JS_NewStringCopyN(js_cx, service_client.udp_buf, service_client.udp_len);
+		datagram = JS_NewStringCopyN(js_cx, (char*)service_client.udp_buf, service_client.udp_len);
 		if(datagram==NULL)
 			val=JSVAL_VOID;
 		else
diff --git a/src/sbbs3/sexyz.c b/src/sbbs3/sexyz.c
index 6ed401da83329120375b6f49cbe189c282bc57b5..cd814b337fe89c4826d7693135c9486d6f21bfee 100644
--- a/src/sbbs3/sexyz.c
+++ b/src/sbbs3/sexyz.c
@@ -1121,7 +1121,7 @@ static int receive_files(char** fname_list, int fnames)
 				}
 				ftime=total_files=0;
 				total_bytes=0;
-				i=sscanf(block+strlen(block)+1,"%"SCNd64" %"SCNoMAX" %lo %lo %u %"SCNd64
+				i=sscanf((char*)block+strlen((char*)block)+1,"%"SCNd64" %"SCNoMAX" %lo %lo %u %"SCNd64
 					,&file_bytes			/* file size (decimal) */
 					,&ftime 				/* file time (octal unix format) */
 					,&fmode 				/* file mode (not used) */
@@ -1129,8 +1129,8 @@ static int receive_files(char** fname_list, int fnames)
 					,&total_files			/* remaining files to be sent */
 					,&total_bytes			/* remaining bytes to be sent */
 					);
-				lprintf(LOG_DEBUG,"YMODEM header (%u fields): %s", i, block+strlen(block)+1);
-				SAFECOPY(fname,block);
+				lprintf(LOG_DEBUG,"YMODEM header (%u fields): %s", i, block+strlen((char*)block)+1);
+				SAFECOPY(fname,(char*)block);
 
 			} else {	/* Zmodem */
 				lprintf(LOG_INFO,"Waiting for ZMODEM sender...");
diff --git a/src/sbbs3/slog.c b/src/sbbs3/slog.c
index 9ab05adbd69519924401795afd67ae1863eaece0..2e2ce40df396c6b06b98e8c23564caf7627b87fd 100644
--- a/src/sbbs3/slog.c
+++ b/src/sbbs3/slog.c
@@ -65,7 +65,7 @@ length=filelength(file);
 if(length<40) {
     close(file);
 	return(1); }
-if((buf=(char *)malloc(length))==0) {
+if((buf=malloc(length))==0) {
     close(file);
 	printf("error allocating %lu bytes\r\n",length);
 	return(1); }
diff --git a/src/sbbs3/smbutil.c b/src/sbbs3/smbutil.c
index dee71a49532687e15eb186bf56b7fa3d8ab7f553..088ebc8c5114caf314434c5d23cb493b33847d28 100644
--- a/src/sbbs3/smbutil.c
+++ b/src/sbbs3/smbutil.c
@@ -155,7 +155,7 @@ void bail(int code)
 /*****************************************************************************/
 /* Expands Unix LF to CRLF													 */
 /*****************************************************************************/
-ulong lf_expand(BYTE* inbuf, BYTE* outbuf)
+ulong lf_expand(uchar* inbuf, uchar* outbuf)
 {
 	ulong	i,j;
 
@@ -176,8 +176,8 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
 {
 	char		str[128];
 	char		buf[1024];
-	char*		msgtxt=NULL;
-	char*		newtxt;
+	uchar*		msgtxt=NULL;
+	uchar*		newtxt;
 	long		msgtxtlen;
 	ushort		net;
 	int 		i;
@@ -191,7 +191,7 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
 		i=fread(buf,1,sizeof(buf),fp);
 		if(i<1)
 			break;
-		if((msgtxt=(char*)realloc(msgtxt,msgtxtlen+i+1))==NULL) {
+		if((msgtxt=(uchar*)realloc(msgtxt,msgtxtlen+i+1))==NULL) {
 			fprintf(errfp,"\n%s!realloc(%ld) failure\n",beep,msgtxtlen+i+1);
 			bail(1);
 		}
@@ -203,7 +203,7 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
 
 		msgtxt[msgtxtlen]=0;	/* Must be NULL-terminated */
 
-		if((newtxt=(char*)malloc((msgtxtlen*2)+1))==NULL) {
+		if((newtxt=(uchar*)malloc((msgtxtlen*2)+1))==NULL) {
 			fprintf(errfp,"\n%s!malloc(%ld) failure\n",beep,(msgtxtlen*2)+1);
 			bail(1);
 		}
@@ -608,7 +608,7 @@ void dump_hashes(void)
 		if(hash.flags&SMB_HASH_CRC32)
 			printf("%-10s: %08"PRIx32"\n","CRC-32",	hash.crc32);
 		if(hash.flags&SMB_HASH_MD5)
-			printf("%-10s: %s\n",	"MD5",		MD5_hex(tmp,hash.md5));
+			printf("%-10s: %s\n",	"MD5",		MD5_hex((BYTE*)tmp,hash.md5));
 	}
 
 	smb_close_hash(&smb);
@@ -814,7 +814,8 @@ typedef struct {
 /****************************************************************************/
 void packmsgs(ulong packable)
 {
-	uchar str[128],buf[SDT_BLOCK_LEN],ch,fname[128],tmpfname[128];
+	uchar	buf[SDT_BLOCK_LEN],ch;
+	char	str[128],fname[128],tmpfname[128];
 	int i,size;
 	ulong l,m,n,datoffsets=0,length,total;
 	FILE *tmp_sdt,*tmp_shd,*tmp_sid;
diff --git a/src/sbbs3/unbaja.c b/src/sbbs3/unbaja.c
index c593c1878608bf0f58404063f8936ee3b3989568..5eef2f6fdca10d29623d9b3bf3891d3e90500ef0 100644
--- a/src/sbbs3/unbaja.c
+++ b/src/sbbs3/unbaja.c
@@ -216,13 +216,13 @@ void add_bruted(unsigned long name, char good, char *val, int save)
 	}
 }
 
-int check_bruted(long name,char *val)
+int check_bruted(long name,unsigned char *val)
 {
 	int i;
 
 	for(i=0; i<bruted_len; i++) {
 		if(*(int32_t *)bruted[i]==name) {
-			if(!strcmp(val,bruted[i]+5))
+			if(!strcmp((char*)val,bruted[i]+5))
 				return(*(bruted[i]+4));
 		}
 	}
@@ -307,7 +307,7 @@ LOOP_END:
 				case 0:
 					break;
 				case 2:
-					add_bruted(name,1,brute_buf,1);
+					add_bruted(name,1,(char*)brute_buf,1);
 				case 1:
 					goto BRUTE_DONE;
 			}
@@ -320,7 +320,7 @@ LOOP_END:
 
 BRUTE_DONE:
 	printf("\r%s Found!\n",brute_buf);
-	return(brute_buf);
+	return((char*)brute_buf);
 }
 
 /* comparison function for var_table */
@@ -2338,7 +2338,7 @@ int main(int argc, char **argv)
 		if(!strncmp(argv[f],"-b",2)) {
 			brute_len=atoi(argv[f]+2);
 			if(brute_len) {
-				brute_buf=(char *)malloc(brute_len+1);
+				brute_buf=malloc(brute_len+1);
 				if(!brute_buf)
 					brute_len=0;
 				brute_crc_buf=(uint32_t *)malloc(brute_len*sizeof(uint32_t));
diff --git a/src/sbbs3/websrvr.c b/src/sbbs3/websrvr.c
index edf8fe96771c751526466bc4240f1e3a6ecb73d6..58ab48f924ae82565507e94a76583bac9832cf25 100644
--- a/src/sbbs3/websrvr.c
+++ b/src/sbbs3/websrvr.c
@@ -101,7 +101,7 @@ enum {
 
 static scfg_t	scfg;
 static volatile BOOL	http_logging_thread_running=FALSE;
-static protected_int32_t active_clients;
+static protected_uint32_t active_clients;
 static volatile ulong	sockets=0;
 static volatile BOOL	terminate_server=FALSE;
 static volatile BOOL	terminate_http_logging_thread=FALSE;
@@ -524,7 +524,7 @@ static int writebuf(http_session_t	*session, const char *buf, size_t len)
 		}
 		if(avail > len-sent)
 			avail=len-sent;
-		sent+=RingBufWrite(&(session->outbuf), ((char *)buf)+sent, avail);
+		sent+=RingBufWrite(&(session->outbuf), ((const BYTE *)buf)+sent, avail);
 	}
 	return(sent);
 }
@@ -1599,7 +1599,7 @@ static BOOL check_ars(http_session_t * session)
 				MD5_digest(&ctx, ":", 1);
 				MD5_digest(&ctx, thisuser.pass, strlen(thisuser.pass));
 				MD5_close(&ctx, digest);
-				MD5_hex(ha1, digest);
+				MD5_hex((BYTE*)ha1, digest);
 
 				/* H(A1)l */
 				pass=strdup(thisuser.pass);
@@ -1611,7 +1611,7 @@ static BOOL check_ars(http_session_t * session)
 				MD5_digest(&ctx, ":", 1);
 				MD5_digest(&ctx, pass, strlen(pass));
 				MD5_close(&ctx, digest);
-				MD5_hex(ha1l, digest);
+				MD5_hex((BYTE*)ha1l, digest);
 
 				/* H(A1)u */
 				strupr(pass);
@@ -1622,7 +1622,7 @@ static BOOL check_ars(http_session_t * session)
 				MD5_digest(&ctx, ":", 1);
 				MD5_digest(&ctx, thisuser.pass, strlen(thisuser.pass));
 				MD5_close(&ctx, digest);
-				MD5_hex(ha1u, digest);
+				MD5_hex((BYTE*)ha1u, digest);
 				free(pass);
 
 				/* H(A2) */
@@ -1635,7 +1635,7 @@ static BOOL check_ars(http_session_t * session)
 				if(session->req.auth.qop_value == QOP_AUTH_INT)
 					return(FALSE);
 				MD5_close(&ctx, digest);
-				MD5_hex(ha2, digest);
+				MD5_hex((BYTE*)ha2, digest);
 
 				/* Check password as in user.dat */
 				calculate_digest(session, ha1, ha2, digest);
@@ -4992,7 +4992,7 @@ void http_output_thread(void *arg)
 		}
 
 		pthread_mutex_lock(&session->outbuf_write);
-        RingBufRead(obuf, bufdata, avail);
+        RingBufRead(obuf, (uchar*)bufdata, avail);
 		if(chunked) {
 			bufdata+=avail;
 			*(bufdata++)='\r';
@@ -5112,7 +5112,7 @@ void http_session_thread(void* arg)
 		return;
 	}
 
-	protected_int32_adjust(&active_clients, 1);
+	protected_uint32_adjust(&active_clients, 1);
 	update_clients();
 	SAFECOPY(session.username,unknown);
 
@@ -5230,7 +5230,7 @@ void http_session_thread(void* arg)
 	sem_destroy(&session.output_thread_terminated);
 	RingBufDispose(&session.outbuf);
 
-	clients_remain=protected_int32_adjust(&active_clients, -1);
+	clients_remain=protected_uint32_adjust(&active_clients, -1);
 	update_clients();
 	client_off(socket);
 
@@ -5278,7 +5278,7 @@ static void cleanup(int code)
 	if(active_clients.value)
 		lprintf(LOG_WARNING,"#### Web Server terminating with %ld active clients", active_clients.value);
 	else
-		protected_int32_destroy(active_clients);
+		protected_uint32_destroy(active_clients);
 
 	update_clients();
 
@@ -5609,7 +5609,7 @@ void DLLCALL web_server(void* arg)
 		if(uptime==0)
 			uptime=time(NULL);	/* this must be done *after* setting the timezone */
 
-		protected_int32_init(&active_clients,0);
+		protected_uint32_init(&active_clients,0);
 		update_clients();
 
 		/* open a socket and wait for a client */
diff --git a/src/sbbs3/writemsg.cpp b/src/sbbs3/writemsg.cpp
index 1a13ce9ac1e10c439e28f1cd7f6290529c1b4033..4ab1538d000821b272c9ed1e9da6439723d9cda5 100644
--- a/src/sbbs3/writemsg.cpp
+++ b/src/sbbs3/writemsg.cpp
@@ -188,7 +188,7 @@ int sbbs_t::process_edited_file(const char* src, const char* dest, long mode, un
 /* message and 'title' is the title (70chars max) for the message.          */
 /* 'dest' contains a text description of where the message is going.        */
 /****************************************************************************/
-bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode, int subnum
+bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode, uint subnum
 	,const char *dest, char** editor)
 {
 	char	str[256],quote[128],c,*buf,*p,*tp
diff --git a/src/sbbs3/xmodem.c b/src/sbbs3/xmodem.c
index ce21586644a8016d5b65b241ae9528e5db88fdcb..3d4ab3ef70e2dbd54db27226b3cd976ccb8b1e6a 100644
--- a/src/sbbs3/xmodem.c
+++ b/src/sbbs3/xmodem.c
@@ -473,7 +473,7 @@ BOOL xmodem_put_eot(xmodem_t* xm)
 	return(FALSE);
 }
 
-BOOL xmodem_send_file(xmodem_t* xm, const char* fname, FILE* fp, time_t* start, int64_t* sent)
+BOOL xmodem_send_file(xmodem_t* xm, const char* fname, FILE* fp, time_t* start, uint64_t* sent)
 {
 	BOOL		success=FALSE;
 	int64_t		sent_bytes=0;
@@ -519,7 +519,7 @@ BOOL xmodem_send_file(xmodem_t* xm, const char* fname, FILE* fp, time_t* start,
 			
 			block_len=strlen(block)+1+i;
 			for(xm->errors=0;xm->errors<=xm->max_errors && !is_cancelled(xm) && is_connected(xm);xm->errors++) {
-				xmodem_put_block(xm, block, block_len <=XMODEM_MIN_BLOCK_SIZE ? XMODEM_MIN_BLOCK_SIZE:XMODEM_MAX_BLOCK_SIZE, 0  /* block_num */);
+				xmodem_put_block(xm, (uchar*)block, block_len <=XMODEM_MIN_BLOCK_SIZE ? XMODEM_MIN_BLOCK_SIZE:XMODEM_MAX_BLOCK_SIZE, 0  /* block_num */);
 				if((i=xmodem_get_ack(xm,/* tries: */1, /* block_num: */0)) == ACK) {
 					sent_header=TRUE;
 					break; 
@@ -570,7 +570,7 @@ BOOL xmodem_send_file(xmodem_t* xm, const char* fname, FILE* fp, time_t* start,
 			}
 			if(xm->progress!=NULL)
 				xm->progress(xm->cbdata,block_num,ftello(fp),st.st_size,startfile);
-			xmodem_put_block(xm, block, xm->block_size, block_num);
+			xmodem_put_block(xm, (uchar*)block, xm->block_size, block_num);
 			if(xmodem_get_ack(xm, /* tries: */5,block_num) != ACK) {
 				xm->errors++;
 				lprintf(xm,LOG_WARNING,"Block %u: Error #%d at offset %"PRId64
diff --git a/src/sbbs3/xmodem.h b/src/sbbs3/xmodem.h
index 74f09e2600c37fb7a7c8c1befb97faa911922394..0dce4f3e8b7394fa8310aaad23a03325636673d6 100644
--- a/src/sbbs3/xmodem.h
+++ b/src/sbbs3/xmodem.h
@@ -96,6 +96,6 @@ int			xmodem_put_ack(xmodem_t*);
 int			xmodem_put_nak(xmodem_t*, unsigned block_num);
 int			xmodem_get_block(xmodem_t*, uchar* block, unsigned block_num);
 int			xmodem_put_block(xmodem_t*, uchar* block, unsigned block_size, unsigned block_num);
-BOOL		xmodem_send_file(xmodem_t* xm, const char* fname, FILE* fp, time_t* start, int64_t* sent);
+BOOL		xmodem_send_file(xmodem_t* xm, const char* fname, FILE* fp, time_t* start, uint64_t* sent);
 
 #endif	/* Don't add anything after this line */
diff --git a/src/sbbs3/xtrn.cpp b/src/sbbs3/xtrn.cpp
index d70af16f81907bd6829eb89a72feaaec4c3d2ad2..c72de6cf8ebfcd5e1854c885bddde5f23f63253d 100644
--- a/src/sbbs3/xtrn.cpp
+++ b/src/sbbs3/xtrn.cpp
@@ -1978,7 +1978,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
 			lprintf(LOG_NOTICE,"%.*s",i,buf);
 	}
 #else
-	waitpid(pid, &i, 0)==0;
+	waitpid(pid, &i, 0);
 #endif
 
 	if(!(mode&EX_OFFLINE)) {	/* !off-line execution */
diff --git a/src/sbbs3/zmodem.c b/src/sbbs3/zmodem.c
index d92796160a8aebbc449d51e44493c875541a3b82..85162d50e53a6b507f617b6c6d91a5bd7a0bf7e7 100644
--- a/src/sbbs3/zmodem.c
+++ b/src/sbbs3/zmodem.c
@@ -1652,7 +1652,7 @@ int zmodem_send_from(zmodem_t* zm, FILE* fp, uint64_t pos, uint64_t* sent)
  * send a file; returns true when session is successful. (or file is skipped)
  */
 
-BOOL zmodem_send_file(zmodem_t* zm, char* fname, FILE* fp, BOOL request_init, time_t* start, int64_t* sent)
+BOOL zmodem_send_file(zmodem_t* zm, char* fname, FILE* fp, BOOL request_init, time_t* start, uint64_t* sent)
 {
 	uint64_t	pos=0;
 	uint64_t	sent_bytes;
@@ -1764,18 +1764,18 @@ BOOL zmodem_send_file(zmodem_t* zm, char* fname, FILE* fp, BOOL request_init, ti
 
 	p = zm->tx_data_subpacket;
 
-	SAFECOPY(zm->tx_data_subpacket,getfname(fname));
+	SAFECOPY(((char*)zm->tx_data_subpacket),getfname(fname));
 
-	p += strlen(p) + 1;
+	p += strlen((char*)p) + 1;
 
-	sprintf(p,"%"PRId64" %"PRIoMAX" 0 0 %u %"PRId64" 0"
+	sprintf((char*)p,"%"PRId64" %"PRIoMAX" 0 0 %u %"PRId64" 0"
 		,zm->current_file_size	/* use for estimating only, could be zero! */
 		,(uintmax_t)s.st_mtime
 		,zm->files_remaining
 		,zm->bytes_remaining
 		);
 
-	p += strlen(p) + 1;
+	p += strlen((char*)p) + 1;
 
 	for(attempts=0;;attempts++) {
 
@@ -1787,7 +1787,7 @@ BOOL zmodem_send_file(zmodem_t* zm, char* fname, FILE* fp, BOOL request_init, ti
 	 	 */
 
 		lprintf(zm,LOG_DEBUG,"Sending ZFILE frame: '%s'"
-			,zm->tx_data_subpacket+strlen(zm->tx_data_subpacket)+1);
+			,zm->tx_data_subpacket+strlen((char*)zm->tx_data_subpacket)+1);
 
 		if((i=zmodem_send_bin_header(zm,zfile_frame))!=0) {
 			lprintf(zm,LOG_DEBUG,"zmodem_send_bin_header returned %d",i);
@@ -2110,14 +2110,14 @@ void zmodem_parse_zfile_subpacket(zmodem_t* zm)
 	long		serial=-1L;
 	ulong		tmptime;
 
-	SAFECOPY(zm->current_file_name,getfname(zm->rx_data_subpacket));
+	SAFECOPY(zm->current_file_name,getfname((char*)zm->rx_data_subpacket));
 
 	zm->current_file_size = 0;
 	zm->current_file_time = 0;
 	zm->files_remaining = 0;
 	zm->bytes_remaining = 0;
 
-	i=sscanf(zm->rx_data_subpacket+strlen(zm->rx_data_subpacket)+1,"%"SCNd64" %lo %o %lo %u %"SCNd64
+	i=sscanf((char*)zm->rx_data_subpacket+strlen((char*)zm->rx_data_subpacket)+1,"%"SCNd64" %lo %o %lo %u %"SCNd64
 		,&zm->current_file_size	/* file size (decimal) */
 		,&tmptime				/* file time (octal unix format) */
 		,&mode					/* file mode */
@@ -2128,7 +2128,7 @@ void zmodem_parse_zfile_subpacket(zmodem_t* zm)
 	zm->current_file_time=tmptime;
 
 	lprintf(zm,LOG_DEBUG,"Zmodem file (ZFILE) data (%u fields): %s"
-		,i, zm->rx_data_subpacket+strlen(zm->rx_data_subpacket)+1);
+		,i, zm->rx_data_subpacket+strlen((char*)zm->rx_data_subpacket)+1);
 
 	if(!zm->files_remaining)
 		zm->files_remaining = 1;
diff --git a/src/sbbs3/zmodem.h b/src/sbbs3/zmodem.h
index 55267011deed836ddd114557c2aadff6e0e1a288..465be36a6d8e283c868db746af4830481dad8b99 100644
--- a/src/sbbs3/zmodem.h
+++ b/src/sbbs3/zmodem.h
@@ -315,7 +315,7 @@ BOOL		zmodem_get_crc(zmodem_t*, int32_t length, uint32_t* crc);
 void		zmodem_parse_zrinit(zmodem_t*);
 void		zmodem_parse_zfile_subpacket(zmodem_t* zm);
 int			zmodem_send_zfin(zmodem_t*);
-BOOL		zmodem_send_file(zmodem_t*, char* name, FILE* fp, BOOL request_init, time_t* start, int64_t* bytes_sent);
+BOOL		zmodem_send_file(zmodem_t*, char* name, FILE* fp, BOOL request_init, time_t* start, uint64_t* bytes_sent);
 int			zmodem_recv_files(zmodem_t* zm, const char* download_dir, int64_t* bytes_received);
 int			zmodem_recv_init(zmodem_t* zm);
 unsigned	zmodem_recv_file_data(zmodem_t*, FILE*, int64_t offset);
diff --git a/src/smblib/smbdefs.h b/src/smblib/smbdefs.h
index e030b06704cd72c51764292887de18a605277195..127a7055f790ff760a8573d7ca30926959438fb3 100644
--- a/src/smblib/smbdefs.h
+++ b/src/smblib/smbdefs.h
@@ -644,8 +644,8 @@ typedef struct {			/* Message base */
 
 	/* Private member variables (not initialized by or used by smblib) */
 	uint32_t	subnum;			/* Sub-board number */
-	int32_t		msgs;			/* Number of messages loaded (for user) */
-	int32_t		curmsg;			/* Current message number (for user) */
+	uint32_t	msgs;			/* Number of messages loaded (for user) */
+	uint32_t	curmsg;			/* Current message number (for user) */
 
 } smb_t;