diff --git a/src/sbbs3/scfglib.h b/src/sbbs3/scfglib.h
index afad4848551d41ed795efd09eda8b258868ff9f0..e1e301779187fe60145e44984e798642f7410a94 100644
--- a/src/sbbs3/scfglib.h
+++ b/src/sbbs3/scfglib.h
@@ -60,7 +60,7 @@ extern const uchar* nular;
 #define FREE_AR(x)		if(x!=NULL && x!=nular)	{ FREE(x); x=NULL; }	
 
 char*	get_alloc(long *offset, char *outstr, int maxlen, FILE *instream);
-BOOL	allocerr(char* error, long offset, char *fname, uint size);
+BOOL	allocerr(FILE*, char* error, long offset, char *fname, uint size);
 char*	readline(long *offset, char *str, int maxlen, FILE *stream);
 
 BOOL	read_node_cfg(scfg_t* cfg, char* error);
diff --git a/src/sbbs3/scfglib1.c b/src/sbbs3/scfglib1.c
index de60fa4697a14270456d17c4c568a0d3f0e8c1cb..08ba788f5ab165976bdef41ec7ae1d192090f584 100644
--- a/src/sbbs3/scfglib1.c
+++ b/src/sbbs3/scfglib1.c
@@ -48,10 +48,11 @@ const char *scfgnulstr="";
 	truncsp()
 ***/
 
-BOOL allocerr(char* error, long offset, char *fname, uint size)
+BOOL allocerr(FILE* fp, char* error, long offset, char *fname, uint size)
 {
 	sprintf(error,"offset %ld in %s, allocating %u bytes of memory"
 		,offset,fname,size);
+	fclose(fp);
 	return(FALSE);
 }
 
@@ -77,6 +78,7 @@ BOOL read_node_cfg(scfg_t* cfg, char* error)
 	if(!cfg->node_num) {
 		sprintf(error,"offset %ld in %s, Node number must be non-zero"
 			,offset,fname);
+		fclose(instream);
 		return(FALSE); 
 	}
 	get_str(cfg->node_name,instream);
@@ -157,7 +159,7 @@ BOOL read_node_cfg(scfg_t* cfg, char* error)
 	if(cfg->mdm_results) {
 		if((cfg->mdm_result=(mdm_result_t *)MALLOC(sizeof(mdm_result_t)*cfg->mdm_results))
 			==NULL)
-		return allocerr(error,offset,fname,sizeof(mdm_result_t *)*cfg->mdm_results);
+		return allocerr(instream,error,offset,fname,sizeof(mdm_result_t *)*cfg->mdm_results);
 	} else
 		cfg->mdm_result=NULL;
 
@@ -207,13 +209,14 @@ BOOL read_main_cfg(scfg_t* cfg, char* error)
 		else
 			sprintf(error,"Total nodes (%u) < node number in NODE.CNF (%u)"
 				,cfg->sys_nodes,cfg->node_num);
+		fclose(instream);
 		return(FALSE); 
 	}
 
 #if 0	/* old dynamic way */
 
 	if((cfg->node_path=(char **)MALLOC(sizeof(char *)*cfg->sys_nodes))==NULL)
-		return allocerr(error,offset,fname,sizeof(char *)*cfg->sys_nodes);
+		return allocerr(instream,error,offset,fname,sizeof(char *)*cfg->sys_nodes);
 
 	for(i=0;i<cfg->sys_nodes;i++) {
 		if(feof(instream)) break;
@@ -221,7 +224,7 @@ BOOL read_main_cfg(scfg_t* cfg, char* error)
 		prep_dir(cfg->ctrl_dir, str);
 		offset+=LEN_DIR+1;
 		if((cfg->node_path[i]=(char *)MALLOC(strlen(str)+1))==NULL)
-			return allocerr(error,offset,fname,strlen(str)+1);
+			return allocerr(instream,error,offset,fname,strlen(str)+1);
 		strcpy(cfg->node_path[i],str); 
 	}
 
@@ -337,11 +340,13 @@ BOOL read_main_cfg(scfg_t* cfg, char* error)
 
 	for(i=0;i<100 && !feof(instream);i++) {
 		get_int(cfg->level_timeperday[i],instream);
+#if 0	/* removed May 06, 2002 */
 		if(cfg->level_timeperday[i]>500)
 			cfg->level_timeperday[i]=500;
 		get_int(cfg->level_timepercall[i],instream);
 		if(cfg->level_timepercall[i]>500)
 			cfg->level_timepercall[i]=500;
+#endif
 		get_int(cfg->level_callsperday[i],instream);
 		get_int(cfg->level_freecdtperday[i],instream);
 		get_int(cfg->level_linespermsg[i],instream);
@@ -356,6 +361,7 @@ BOOL read_main_cfg(scfg_t* cfg, char* error)
 	if(i!=100) {
 		sprintf(error,"Insufficient User Level Information"
 			"%d user levels read, 100 needed.",i);
+		fclose(instream);
 		return(FALSE); 
 	}
 
@@ -363,20 +369,21 @@ BOOL read_main_cfg(scfg_t* cfg, char* error)
 	#ifdef SBBS
 	if(!cfg->total_shells) {
 		sprintf(error,"At least one command shell must be configured.");
+		fclose(instream);
 		return(FALSE); 
 	}
 	#endif
 
 	if(cfg->total_shells) {
 		if((cfg->shell=(shell_t **)MALLOC(sizeof(shell_t *)*cfg->total_shells))==NULL)
-			return allocerr(error,offset,fname,sizeof(shell_t *)*cfg->total_shells);
+			return allocerr(instream,error,offset,fname,sizeof(shell_t *)*cfg->total_shells);
 	} else
 		cfg->shell=NULL;
 
 	for(i=0;i<cfg->total_shells;i++) {
 		if(feof(instream)) break;
 		if((cfg->shell[i]=(shell_t *)MALLOC(sizeof(shell_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(shell_t));
+			return allocerr(instream,error,offset,fname,sizeof(shell_t));
 		memset(cfg->shell[i],0,sizeof(shell_t));
 
 		get_str(cfg->shell[i]->name,instream);
@@ -437,7 +444,7 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_grps) {
 		if((cfg->grp=(grp_t **)MALLOC(sizeof(grp_t *)*cfg->total_grps))==NULL)
-			return allocerr(error,offset,fname,sizeof(grp_t *)*cfg->total_grps);
+			return allocerr(instream,error,offset,fname,sizeof(grp_t *)*cfg->total_grps);
 	} else
 		cfg->grp=NULL;
 
@@ -445,7 +452,7 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error)
 
 		if(feof(instream)) break;
 		if((cfg->grp[i]=(grp_t *)MALLOC(sizeof(grp_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(grp_t));
+			return allocerr(instream,error,offset,fname,sizeof(grp_t));
 		memset(cfg->grp[i],0,sizeof(grp_t));
 
 		get_str(cfg->grp[i]->lname,instream);
@@ -467,14 +474,14 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_subs) {
 		if((cfg->sub=(sub_t **)MALLOC(sizeof(sub_t *)*cfg->total_subs))==NULL)
-			return allocerr(error,offset,fname,sizeof(sub_t *)*cfg->total_subs);
+			return allocerr(instream,error,offset,fname,sizeof(sub_t *)*cfg->total_subs);
 	} else
 		cfg->sub=NULL;
 
 	for(i=0;i<cfg->total_subs;i++) {
 		if(feof(instream)) break;
 		if((cfg->sub[i]=(sub_t *)MALLOC(sizeof(sub_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(sub_t));
+			return allocerr(instream,error,offset,fname,sizeof(sub_t));
 		memset(cfg->sub[i],0,sizeof(sub_t));
 
 		get_int(cfg->sub[i]->grp,instream);
@@ -518,6 +525,7 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error)
 				sprintf(error,"offset %ld in %s: Duplicate pointer index for subs #%d and #%d"
 					,offset,fname
 					,i+1,j+1);
+				fclose(instream);
 				return(FALSE); 
 			}
 #endif
@@ -540,7 +548,7 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_faddrs) {
 		if((cfg->faddr=(faddr_t *)MALLOC(sizeof(faddr_t)*cfg->total_faddrs))==NULL)
-			return allocerr(error,offset,fname,sizeof(faddr_t)*cfg->total_faddrs);
+			return allocerr(instream,error,offset,fname,sizeof(faddr_t)*cfg->total_faddrs);
 	} else
 		cfg->faddr=NULL;
 
@@ -569,14 +577,14 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_qhubs) {
 		if((cfg->qhub=(qhub_t **)MALLOC(sizeof(qhub_t *)*cfg->total_qhubs))==NULL)
-			return allocerr(error,offset,fname,sizeof(qhub_t*)*cfg->total_qhubs);
+			return allocerr(instream,error,offset,fname,sizeof(qhub_t*)*cfg->total_qhubs);
 	} else
 		cfg->qhub=NULL;
 
 	for(i=0;i<cfg->total_qhubs;i++) {
 		if(feof(instream)) break;
 		if((cfg->qhub[i]=(qhub_t *)MALLOC(sizeof(qhub_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(qhub_t));
+			return allocerr(instream,error,offset,fname,sizeof(qhub_t));
 		memset(cfg->qhub[i],0,sizeof(qhub_t));
 
 		get_str(cfg->qhub[i]->id,instream);
@@ -591,11 +599,11 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error)
 
 		if(k) {
 			if((cfg->qhub[i]->sub=(ushort *)MALLOC(sizeof(ushort)*k))==NULL)
-				return allocerr(error,offset,fname,sizeof(uint)*k);
+				return allocerr(instream,error,offset,fname,sizeof(uint)*k);
 			if((cfg->qhub[i]->conf=(ushort *)MALLOC(sizeof(ushort)*k))==NULL)
-				return allocerr(error,offset,fname,sizeof(ushort)*k);
+				return allocerr(instream,error,offset,fname,sizeof(ushort)*k);
 			if((cfg->qhub[i]->mode=(char *)MALLOC(sizeof(char)*k))==NULL)
-				return allocerr(error,offset,fname,sizeof(uchar)*k);
+				return allocerr(instream,error,offset,fname,sizeof(uchar)*k);
 		}
 
 		for(j=0;j<k;j++) {
@@ -629,14 +637,14 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_phubs) {
 		if((cfg->phub=(phub_t **)MALLOC(sizeof(phub_t *)*cfg->total_phubs))==NULL)
-			return allocerr(error,offset,fname,sizeof(phub_t*)*cfg->total_phubs);
+			return allocerr(instream,error,offset,fname,sizeof(phub_t*)*cfg->total_phubs);
 	} else
 		cfg->phub=NULL;
 
 	for(i=0;i<cfg->total_phubs;i++) {
 		if(feof(instream)) break;
 		if((cfg->phub[i]=(phub_t *)MALLOC(sizeof(phub_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(phub_t));
+			return allocerr(instream,error,offset,fname,sizeof(phub_t));
 		memset(cfg->phub[i],0,sizeof(phub_t));
 
 		get_str(cfg->phub[i]->name,instream);
diff --git a/src/sbbs3/scfglib2.c b/src/sbbs3/scfglib2.c
index 4bb90cc361c8e236a9af1529c1f4c8c94ba21b24..5da1058be979a29e79a5b7587eecf828c0d3287a 100644
--- a/src/sbbs3/scfglib2.c
+++ b/src/sbbs3/scfglib2.c
@@ -82,7 +82,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_fextrs) {
 		if((cfg->fextr=(fextr_t **)MALLOC(sizeof(fextr_t *)*cfg->total_fextrs))==NULL)
-			return allocerr(error,offset,fname,sizeof(fextr_t*)*cfg->total_fextrs); 
+			return allocerr(instream,error,offset,fname,sizeof(fextr_t*)*cfg->total_fextrs); 
 	} else
 		cfg->fextr=NULL;
 
@@ -90,7 +90,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 		if(feof(instream))
 			break;
 		if((cfg->fextr[i]=(fextr_t *)MALLOC(sizeof(fextr_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(fextr_t));
+			return allocerr(instream,error,offset,fname,sizeof(fextr_t));
 		memset(cfg->fextr[i],0,sizeof(fextr_t));
 		get_str(cfg->fextr[i]->ext,instream);
 		get_str(cfg->fextr[i]->cmd,instream);
@@ -110,7 +110,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_fcomps) {
 		if((cfg->fcomp=(fcomp_t **)MALLOC(sizeof(fcomp_t *)*cfg->total_fcomps))==NULL)
-			return allocerr(error,offset,fname,sizeof(fcomp_t*)*cfg->total_fcomps); 
+			return allocerr(instream,error,offset,fname,sizeof(fcomp_t*)*cfg->total_fcomps); 
 	} else
 		cfg->fcomp=NULL;
 
@@ -118,7 +118,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 		if(feof(instream))
 			break;
 		if((cfg->fcomp[i]=(fcomp_t *)MALLOC(sizeof(fcomp_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(fcomp_t));
+			return allocerr(instream,error,offset,fname,sizeof(fcomp_t));
 		memset(cfg->fcomp[i],0,sizeof(fcomp_t));
 		get_str(cfg->fcomp[i]->ext,instream);
 		get_str(cfg->fcomp[i]->cmd,instream);
@@ -138,14 +138,14 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_fviews) {
 		if((cfg->fview=(fview_t **)MALLOC(sizeof(fview_t *)*cfg->total_fviews))==NULL)
-			return allocerr(error,offset,fname,sizeof(fview_t*)*cfg->total_fviews); 
+			return allocerr(instream,error,offset,fname,sizeof(fview_t*)*cfg->total_fviews); 
 	} else
 		cfg->fview=NULL;
 
 	for(i=0; i<cfg->total_fviews; i++) {
 		if(feof(instream)) break;
 		if((cfg->fview[i]=(fview_t *)MALLOC(sizeof(fview_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(fview_t));
+			return allocerr(instream,error,offset,fname,sizeof(fview_t));
 		memset(cfg->fview[i],0,sizeof(fview_t));
 		get_str(cfg->fview[i]->ext,instream);
 		get_str(cfg->fview[i]->cmd,instream);
@@ -165,14 +165,14 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_ftests) {
 		if((cfg->ftest=(ftest_t **)MALLOC(sizeof(ftest_t *)*cfg->total_ftests))==NULL)
-			return allocerr(error,offset,fname,sizeof(ftest_t*)*cfg->total_ftests); 
+			return allocerr(instream,error,offset,fname,sizeof(ftest_t*)*cfg->total_ftests); 
 	} else
 		cfg->ftest=NULL;
 
 	for(i=0; i<cfg->total_ftests; i++) {
 		if(feof(instream)) break;
 		if((cfg->ftest[i]=(ftest_t *)MALLOC(sizeof(ftest_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(ftest_t));
+			return allocerr(instream,error,offset,fname,sizeof(ftest_t));
 		memset(cfg->ftest[i],0,sizeof(ftest_t));
 		get_str(cfg->ftest[i]->ext,instream);
 		get_str(cfg->ftest[i]->cmd,instream);
@@ -194,14 +194,14 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 	if(cfg->total_dlevents) {
 		if((cfg->dlevent=(dlevent_t **)MALLOC(sizeof(dlevent_t *)*cfg->total_dlevents))
 			==NULL)
-			return allocerr(error,offset,fname,sizeof(dlevent_t*)*cfg->total_dlevents); 
+			return allocerr(instream,error,offset,fname,sizeof(dlevent_t*)*cfg->total_dlevents); 
 	} else
 		cfg->dlevent=NULL;
 
 	for(i=0; i<cfg->total_dlevents; i++) {
 		if(feof(instream)) break;
 		if((cfg->dlevent[i]=(dlevent_t *)MALLOC(sizeof(dlevent_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(dlevent_t));
+			return allocerr(instream,error,offset,fname,sizeof(dlevent_t));
 		memset(cfg->dlevent[i],0,sizeof(dlevent_t));
 		get_str(cfg->dlevent[i]->ext,instream);
 		get_str(cfg->dlevent[i]->cmd,instream);
@@ -223,14 +223,14 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_prots) {
 		if((cfg->prot=(prot_t **)MALLOC(sizeof(prot_t *)*cfg->total_prots))==NULL)
-			return allocerr(error,offset,fname,sizeof(prot_t*)*cfg->total_prots); 
+			return allocerr(instream,error,offset,fname,sizeof(prot_t*)*cfg->total_prots); 
 	} else
 		cfg->prot=NULL;
 
 	for(i=0;i<cfg->total_prots;i++) {
 		if(feof(instream)) break;
 		if((cfg->prot[i]=(prot_t *)MALLOC(sizeof(prot_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(prot_t));
+			return allocerr(instream,error,offset,fname,sizeof(prot_t));
 		memset(cfg->prot[i],0,sizeof(prot_t));
 
 		get_int(cfg->prot[i]->mnemonic,instream);
@@ -257,7 +257,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->altpaths) {
 		if((cfg->altpath=(char **)MALLOC(sizeof(char *)*cfg->altpaths))==NULL)
-			return allocerr(error,offset,fname,sizeof(char *)*cfg->altpaths); 
+			return allocerr(instream,error,offset,fname,sizeof(char *)*cfg->altpaths); 
 	} else
 		cfg->altpath=NULL;
 
@@ -268,7 +268,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 		backslash(str);
 		j=LEN_DIR+1;
 		if((cfg->altpath[i]=(char *)MALLOC(j))==NULL)
-			return allocerr(error,offset,fname,j);
+			return allocerr(instream,error,offset,fname,j);
 		memset(cfg->altpath[i],0,j);
 		strcpy(cfg->altpath[i],str);
 		for(j=0;j<8;j++)
@@ -285,14 +285,14 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_libs) {
 		if((cfg->lib=(lib_t **)MALLOC(sizeof(lib_t *)*cfg->total_libs))==NULL)
-			return allocerr(error,offset,fname,sizeof(lib_t *)*cfg->total_libs);
+			return allocerr(instream,error,offset,fname,sizeof(lib_t *)*cfg->total_libs);
 	} else
 		cfg->lib=NULL;
 
 	for(i=0;i<cfg->total_libs;i++) {
 		if(feof(instream)) break;
 		if((cfg->lib[i]=(lib_t *)MALLOC(sizeof(lib_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(lib_t));
+			return allocerr(instream,error,offset,fname,sizeof(lib_t));
 		memset(cfg->lib[i],0,sizeof(lib_t));
 		cfg->lib[i]->offline_dir=INVALID_DIR;
 
@@ -316,14 +316,14 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_dirs) {
 		if((cfg->dir=(dir_t **)MALLOC(sizeof(dir_t *)*(cfg->total_dirs+1)))==NULL)
-			return allocerr(error,offset,fname,sizeof(dir_t *)*(cfg->total_dirs+1));
+			return allocerr(instream,error,offset,fname,sizeof(dir_t *)*(cfg->total_dirs+1));
 	} else
 		cfg->dir=NULL;
 
 	for(i=0;i<cfg->total_dirs;i++) {
 		if(feof(instream)) break;
 		if((cfg->dir[i]=(dir_t *)MALLOC(sizeof(dir_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(dir_t));
+			return allocerr(instream,error,offset,fname,sizeof(dir_t));
 		memset(cfg->dir[i],0,sizeof(dir_t));
 
 		get_int(cfg->dir[i]->lib,instream);
@@ -349,7 +349,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 		if(str[0]) {
 			prep_dir(cfg->ctrl_dir, str);
 			if((cfg->dir[i]->data_dir=(char *)MALLOC(strlen(str)+1))==NULL)
-				return allocerr(error,offset,fname,strlen(str)+1);
+				return allocerr(instream,error,offset,fname,strlen(str)+1);
 			strcpy(cfg->dir[i]->data_dir,str); 
 		} else
 			cfg->dir[i]->data_dir=cfg->data_dir_dirs;
@@ -398,14 +398,14 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_txtsecs) {
 		if((cfg->txtsec=(txtsec_t **)MALLOC(sizeof(txtsec_t *)*cfg->total_txtsecs))==NULL)
-			return allocerr(error,offset,fname,sizeof(txtsec_t *)*cfg->total_txtsecs); 
+			return allocerr(instream,error,offset,fname,sizeof(txtsec_t *)*cfg->total_txtsecs); 
 	} else
 		cfg->txtsec=NULL;
 
 	for(i=0;i<cfg->total_txtsecs;i++) {
 		if(feof(instream)) break;
 		if((cfg->txtsec[i]=(txtsec_t *)MALLOC(sizeof(txtsec_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(txtsec_t));
+			return allocerr(instream,error,offset,fname,sizeof(txtsec_t));
 		memset(cfg->txtsec[i],0,sizeof(txtsec_t));
 
 		get_str(cfg->txtsec[i]->name,instream);
@@ -419,7 +419,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error)
 	cfg->total_txtsecs=i;
 
 	fclose(instream);
-	return (TRUE);
+	return(TRUE);
 }
 
 /****************************************************************************/
@@ -447,14 +447,14 @@ BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_swaps) {
 		if((cfg->swap=(swap_t **)MALLOC(sizeof(swap_t *)*cfg->total_swaps))==NULL)
-			return allocerr(error,offset,fname,sizeof(swap_t *)*cfg->total_swaps); 
+			return allocerr(instream,error,offset,fname,sizeof(swap_t *)*cfg->total_swaps); 
 	} else
 		cfg->swap=NULL;
 
 	for(i=0;i<cfg->total_swaps;i++) {
 		if(feof(instream)) break;
 		if((cfg->swap[i]=(swap_t *)MALLOC(sizeof(swap_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(swap_t));
+			return allocerr(instream,error,offset,fname,sizeof(swap_t));
 		get_str(cfg->swap[i]->cmd,instream); 
 	}
 	cfg->total_swaps=i;
@@ -467,14 +467,14 @@ BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_xedits) {
 		if((cfg->xedit=(xedit_t **)MALLOC(sizeof(xedit_t *)*cfg->total_xedits))==NULL)
-			return allocerr(error,offset,fname,sizeof(xedit_t *)*cfg->total_xedits); 
+			return allocerr(instream,error,offset,fname,sizeof(xedit_t *)*cfg->total_xedits); 
 	} else
 		cfg->xedit=NULL;
 
 	for(i=0;i<cfg->total_xedits;i++) {
 		if(feof(instream)) break;
 		if((cfg->xedit[i]=(xedit_t *)MALLOC(sizeof(xedit_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(xedit_t));
+			return allocerr(instream,error,offset,fname,sizeof(xedit_t));
 		memset(cfg->xedit[i],0,sizeof(xedit_t));
 
 		get_str(cfg->xedit[i]->name,instream);
@@ -503,14 +503,14 @@ BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
 	if(cfg->total_xtrnsecs) {
 		if((cfg->xtrnsec=(xtrnsec_t **)MALLOC(sizeof(xtrnsec_t *)*cfg->total_xtrnsecs))
 			==NULL)
-			return allocerr(error,offset,fname,sizeof(xtrnsec_t *)*cfg->total_xtrnsecs);
+			return allocerr(instream,error,offset,fname,sizeof(xtrnsec_t *)*cfg->total_xtrnsecs);
 	} else
 		cfg->xtrnsec=NULL;
 
 	for(i=0;i<cfg->total_xtrnsecs;i++) {
 		if(feof(instream)) break;
 		if((cfg->xtrnsec[i]=(xtrnsec_t *)MALLOC(sizeof(xtrnsec_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(xtrnsec_t));
+			return allocerr(instream,error,offset,fname,sizeof(xtrnsec_t));
 		memset(cfg->xtrnsec[i],0,sizeof(xtrnsec_t));
 
 		get_str(cfg->xtrnsec[i]->name,instream);
@@ -532,14 +532,14 @@ BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_xtrns) {
 		if((cfg->xtrn=(xtrn_t **)MALLOC(sizeof(xtrn_t *)*cfg->total_xtrns))==NULL)
-			return allocerr(error,offset,fname,sizeof(xtrn_t *)*cfg->total_xtrns);
+			return allocerr(instream,error,offset,fname,sizeof(xtrn_t *)*cfg->total_xtrns);
 	} else
 		cfg->xtrn=NULL;
 
 	for(i=0;i<cfg->total_xtrns;i++) {
 		if(feof(instream)) break;
 		if((cfg->xtrn[i]=(xtrn_t *)MALLOC(sizeof(xtrn_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(xtrn_t));
+			return allocerr(instream,error,offset,fname,sizeof(xtrn_t));
 		memset(cfg->xtrn[i],0,sizeof(xtrn_t));
 
 		get_int(cfg->xtrn[i]->sec,instream);
@@ -573,14 +573,14 @@ BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_events) {
 		if((cfg->event=(event_t **)MALLOC(sizeof(event_t *)*cfg->total_events))==NULL)
-			return allocerr(error,offset,fname,sizeof(event_t *)*cfg->total_events);
+			return allocerr(instream,error,offset,fname,sizeof(event_t *)*cfg->total_events);
 	} else
 		cfg->event=NULL;
 
 	for(i=0;i<cfg->total_events;i++) {
 		if(feof(instream)) break;
 		if((cfg->event[i]=(event_t *)MALLOC(sizeof(event_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(event_t));
+			return allocerr(instream,error,offset,fname,sizeof(event_t));
 		memset(cfg->event[i],0,sizeof(event_t));
 
 		get_str(cfg->event[i]->code,instream);
@@ -605,14 +605,14 @@ BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_natvpgms) {
 		if((cfg->natvpgm=(natvpgm_t **)MALLOC(sizeof(natvpgm_t *)*cfg->total_natvpgms))==NULL)
-			return allocerr(error,offset,fname,sizeof(natvpgm_t *)*cfg->total_natvpgms);
+			return allocerr(instream,error,offset,fname,sizeof(natvpgm_t *)*cfg->total_natvpgms);
 	} else
 		cfg->natvpgm=NULL;
 
 	for(i=0;i<cfg->total_natvpgms;i++) {
 		if(feof(instream)) break;
 		if((cfg->natvpgm[i]=(natvpgm_t *)MALLOC(sizeof(natvpgm_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(natvpgm_t));
+			return allocerr(instream,error,offset,fname,sizeof(natvpgm_t));
 		get_str(cfg->natvpgm[i]->name,instream);
 		cfg->natvpgm[i]->misc=0; }
 	cfg->total_natvpgms=i;
@@ -629,14 +629,14 @@ BOOL read_xtrn_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_hotkeys) {
 		if((cfg->hotkey=(hotkey_t **)MALLOC(sizeof(hotkey_t *)*cfg->total_hotkeys))==NULL)
-			return allocerr(error,offset,fname,sizeof(hotkey_t *)*cfg->total_hotkeys);
+			return allocerr(instream,error,offset,fname,sizeof(hotkey_t *)*cfg->total_hotkeys);
 	} else
 		cfg->hotkey=NULL;
 
 	for(i=0;i<cfg->total_hotkeys;i++) {
 		if(feof(instream)) break;
 		if((cfg->hotkey[i]=(hotkey_t *)MALLOC(sizeof(hotkey_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(hotkey_t));
+			return allocerr(instream,error,offset,fname,sizeof(hotkey_t));
 		memset(cfg->hotkey[i],0,sizeof(hotkey_t));
 
 		get_int(cfg->hotkey[i]->key,instream);
@@ -681,14 +681,14 @@ BOOL read_chat_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_gurus) {
 		if((cfg->guru=(guru_t **)MALLOC(sizeof(guru_t *)*cfg->total_gurus))==NULL)
-			return allocerr(error,offset,fname,sizeof(guru_t *)*cfg->total_gurus);
+			return allocerr(instream,error,offset,fname,sizeof(guru_t *)*cfg->total_gurus);
 	} else
 		cfg->guru=NULL;
 
 	for(i=0;i<cfg->total_gurus;i++) {
 		if(feof(instream)) break;
 		if((cfg->guru[i]=(guru_t *)MALLOC(sizeof(guru_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(guru_t));
+			return allocerr(instream,error,offset,fname,sizeof(guru_t));
 		memset(cfg->guru[i],0,sizeof(guru_t));
 
 		get_str(cfg->guru[i]->name,instream);
@@ -711,14 +711,14 @@ BOOL read_chat_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_actsets) {
 		if((cfg->actset=(actset_t **)MALLOC(sizeof(actset_t *)*cfg->total_actsets))==NULL)
-			return allocerr(error,offset,fname,sizeof(actset_t *)*cfg->total_actsets);
+			return allocerr(instream,error,offset,fname,sizeof(actset_t *)*cfg->total_actsets);
 	} else
 		cfg->actset=NULL;
 
 	for(i=0;i<cfg->total_actsets;i++) {
 		if(feof(instream)) break;
 		if((cfg->actset[i]=(actset_t *)MALLOC(sizeof(actset_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(actset_t));
+			return allocerr(instream,error,offset,fname,sizeof(actset_t));
 		get_str(cfg->actset[i]->name,instream);
 		}
 	cfg->total_actsets=i;
@@ -733,14 +733,14 @@ BOOL read_chat_cfg(scfg_t* cfg, char* error)
 	if(cfg->total_chatacts) {
 		if((cfg->chatact=(chatact_t **)MALLOC(sizeof(chatact_t *)*cfg->total_chatacts))
 			==NULL)
-			return allocerr(error,offset,fname,sizeof(chatact_t *)*cfg->total_chatacts);
+			return allocerr(instream,error,offset,fname,sizeof(chatact_t *)*cfg->total_chatacts);
 	} else
 		cfg->chatact=NULL;
 
 	for(i=0;i<cfg->total_chatacts;i++) {
 		if(feof(instream)) break;
 		if((cfg->chatact[i]=(chatact_t *)MALLOC(sizeof(chatact_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(chatact_t));
+			return allocerr(instream,error,offset,fname,sizeof(chatact_t));
 		memset(cfg->chatact[i],0,sizeof(chatact_t));
 
 		get_int(cfg->chatact[i]->actset,instream);
@@ -761,14 +761,14 @@ BOOL read_chat_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_chans) {
 		if((cfg->chan=(chan_t **)MALLOC(sizeof(chan_t *)*cfg->total_chans))==NULL)
-			return allocerr(error,offset,fname,sizeof(chan_t *)*cfg->total_chans);
+			return allocerr(instream,error,offset,fname,sizeof(chan_t *)*cfg->total_chans);
 	} else
 		cfg->chan=NULL;
 
 	for(i=0;i<cfg->total_chans;i++) {
 		if(feof(instream)) break;
 		if((cfg->chan[i]=(chan_t *)MALLOC(sizeof(chan_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(chan_t));
+			return allocerr(instream,error,offset,fname,sizeof(chan_t));
 		memset(cfg->chan[i],0,sizeof(chan_t));
 
 		get_int(cfg->chan[i]->actset,instream);
@@ -796,14 +796,14 @@ BOOL read_chat_cfg(scfg_t* cfg, char* error)
 
 	if(cfg->total_pages) {
 		if((cfg->page=(page_t **)MALLOC(sizeof(page_t *)*cfg->total_pages))==NULL)
-			return allocerr(error,offset,fname,sizeof(page_t *)*cfg->total_pages);
+			return allocerr(instream,error,offset,fname,sizeof(page_t *)*cfg->total_pages);
 	} else
 		cfg->page=NULL;
 
 	for(i=0;i<cfg->total_pages;i++) {
 		if(feof(instream)) break;
 		if((cfg->page[i]=(page_t *)MALLOC(sizeof(page_t)))==NULL)
-			return allocerr(error,offset,fname,sizeof(page_t));
+			return allocerr(instream,error,offset,fname,sizeof(page_t));
 		memset(cfg->page[i],0,sizeof(page_t));
 
 		get_str(cfg->page[i]->cmd,instream);