--- src/interface.c
+++ src/interface.c
@@ -584,6 +584,7 @@
     updating_screen = 1;/* flag unique case */
     update_video_screen();
     updating_screen = 0;
+    reload_opcodes();
 }
 
 
@@ -668,23 +669,23 @@
 
 	    strcpy( temp, " " );
 	    if (ent_no >= 0 && ent_no < entries) {
-		sprintf(temp, "%s/%s", disk_path, namelist[ent_no]->d_name);
+		snprintf(temp, TEMPSIZE, "%s/%s", disk_path, namelist[ent_no]->d_name);
 		if (!strcmp(temp, file_name_6[drive]))
 		    in_drive = 1;
 
 		stat(temp, &statbuf);
 		if (S_ISDIR(statbuf.st_mode))
-		    sprintf(temp, " %s/", namelist[ ent_no ] -> d_name );
+		    snprintf(temp, TEMPSIZE, " %s/", namelist[ ent_no ] -> d_name );
 		else
-		    sprintf(temp, " %s", namelist[ ent_no ] -> d_name );
+		    snprintf(temp, TEMPSIZE, " %s", namelist[ ent_no ] -> d_name );
 	        if (c_interface_cut_name(temp)) {
-		    strcat(temp, " <gz>");
+		    strncat(temp, " <gz>", TEMPSIZE);
 		}
 		/* write protected disk in drive? */
 		else if ((in_drive) && (protected_6[drive]))
-		    strcat(temp, (drive == 0) ? " <r1>" : " <r2>");
+		    strncat(temp, (drive == 0) ? " <r1>" : " <r2>", TEMPSIZE);
 		else if (in_drive)
-		    strcat(temp, (drive == 0) ? " <rw1>" : " <rw2>");
+		    strncat(temp, (drive == 0) ? " <rw1>" : " <rw2>", TEMPSIZE);
 	    }
 
 	    slen = strlen( temp );
@@ -743,7 +744,7 @@
 	{
 	    int len, cmpr = 0;
 
-            sprintf(temp, "%s/%s", disk_path, namelist[ curpos ] -> d_name );
+            snprintf(temp, TEMPSIZE, "%s/%s", disk_path, namelist[ curpos ] -> d_name );
 	    len = strlen(disk_path);
 
 	    /* handle disk currently in the drive */
@@ -790,7 +791,7 @@
 			disk_path[len] = '\0';
 		}
 		else if (strcmp(".", namelist[curpos]->d_name))
-		    sprintf(disk_path + len, "/%s", namelist[curpos]->d_name);
+		    snprintf(disk_path + len, DISKSIZE-len, "/%s", namelist[curpos]->d_name);
 		for (i = 0; i < entries; i++)
 		    free(namelist[ i ]);	/* clean up */
 		free(namelist);
@@ -820,7 +821,7 @@
 		    if (execl("/bin/gzip", "/bin/gzip",
 			      "-d", temp, NULL) == -1)
 		    {
-			sprintf(temp, "%s", sys_errlist[errno]);
+			snprintf(temp, TEMPSIZE, "%s", sys_errlist[errno]);
 			perror("\tproblem");
 			c_interface_print( 1, 21,
 			       "    Problem exec'ing /bin/gzip -d     " );
@@ -829,7 +830,7 @@
 			exit(-1);
 		    }
 		} else {
-		    sprintf(temp, "%s", sys_errlist[errno]);
+		    snprintf(temp, TEMPSIZE, "%s", sys_errlist[errno]);
 		    c_interface_print( 1, 21,
 			       "            Cannot fork!              " );
 		    c_interface_print( 1, 22, temp);
@@ -875,7 +876,7 @@
 			exit(-1);
 		    }
 		} else {
-		    sprintf(temp, "%s", sys_errlist[errno]);
+		    snprintf(temp, TEMPSIZE, "%s", sys_errlist[errno]);
 		    c_interface_print( 1, 21,
 			       "            Cannot fork!              " );
 		    c_interface_print( 1, 22, temp);
@@ -1001,7 +1002,7 @@
 	    switch (i + cur_off)
 	    {
 	    case 0:
-		sprintf(temp, "%03d", MAX_APPLE_DELAY + 1 - apple_speed);
+		snprintf(temp, TEMPSIZE, "%03d", MAX_APPLE_DELAY + 1 - apple_speed);
 		break;
 	    case 1:
 		strncpy(temp, disk_path + cur_pos, 24);
@@ -1009,27 +1010,27 @@
 		break;
 	    case 2:
 #ifdef APPLE_IIE
-		sprintf(temp, "%s", (apple_mode == 0) ? "][+             " :
+		snprintf(temp, TEMPSIZE, "%s", (apple_mode == 0) ? "][+             " :
 				    (apple_mode == 1) ? "][+ undocumented" :
 				                        "//e             ");
 #else
-		sprintf(temp, "%s", (apple_mode == 0) ? "][+             " :
+		snprintf(temp, TEMPSIZE, "%s", (apple_mode == 0) ? "][+             " :
 				                        "][+ undocumented");
 #endif
 		break;
 	    case 3:
-		sprintf(temp, "%s", (color_mode == 0) ? "Black/White " :
+		snprintf(temp, TEMPSIZE, "%s", (color_mode == 0) ? "Black/White " :
 				    (color_mode == 1) ? "Lazy Color  " :
 				    (color_mode == 2) ? "Color       " :
 				    (color_mode == 3) ? "Lazy Interp." :
 				                        "Interpolated");
 		break;
 	    case 4:
-		sprintf(temp, "%s", (sound_mode == 0) ? "Off       " :
+		snprintf(temp, TEMPSIZE, "%s", (sound_mode == 0) ? "Off       " :
 				                        "PC speaker");
 		break;
 	    case 5:
-		sprintf(temp, "%s", (joy_mode == JOY_KYBD)    ? "Linear     " :
+		snprintf(temp, TEMPSIZE, "%s", (joy_mode == JOY_KYBD)    ? "Linear     " :
 				    (joy_mode == JOY_DIGITAL) ? "Digital    " :
                                     (joy_mode == JOY_PCJOY)   ? "PC Joystick" :
 								"Off        ");
@@ -1038,22 +1039,22 @@
 		strcpy( temp, "" );
 		break;
 	    case 7:
-		sprintf(temp, "%02x", joy_range);
+		snprintf(temp, TEMPSIZE, "%02x", joy_range);
 		break;
 	    case 8:
-		sprintf(temp, "%02x", joy_center_x);
+		snprintf(temp, TEMPSIZE, "%02x", joy_center_x);
 		break;
 	    case 9:
-		sprintf(temp, "%02x", joy_center_y);
+		snprintf(temp, TEMPSIZE, "%02x", joy_center_y);
 		break;
 	    case 10:
-		sprintf(temp, "%03d%%", joy_step );
+		snprintf(temp, TEMPSIZE, "%03d%%", joy_step );
 		break;
 	    case 11:
 #ifdef PC_JOYSTICK
-		sprintf(temp, "%ld", js_timelimit);
+		snprintf(temp, TEMPSIZE, "%ld", js_timelimit);
 #else
-		sprintf(temp, "%s", "");
+		snprintf(temp, TEMPSIZE, "%s", "");
 #endif
 		break;
 	    case SAVE_SETTINGS:		/* save settings */
@@ -1320,11 +1321,11 @@
 	    if (ch >= ' ' && ch < 127 && option == PATH_OPTION) {
 		int		i;
 
-		strcpy(temp, disk_path);		
+		strncpy(temp, disk_path, TEMPSIZE);		
 		for (i = strlen(temp); i >= cur_pos + cur_x; i--)
 		    temp[ i + 1 ] = temp[ i ];
 		temp[ cur_pos + cur_x ] = ch;
-		strcpy(disk_path, temp);
+		strncpy(disk_path, temp, DISKSIZE);
 		if (cur_x < 23)
 		    cur_x++;
 		else
--- src/misc.c
+++ src/misc.c
@@ -1140,7 +1140,7 @@
 
      if (!ii_rom_loaded)
      {
-         sprintf(temp, "%s/apple_II.rom", system_path);
+         snprintf(temp, TEMPSIZE, "%s/apple_II.rom", system_path);
          if ((f = fopen(temp, "r")) == NULL) {
 	     printf("OOPS!\n");
              printf("Cannot find file '%s'.\n",temp);
@@ -1153,7 +1153,7 @@
 
 #ifdef APPLE_IIE
      if (!iie_rom_loaded) {
-	 sprintf(temp, "%s/apple_IIe.rom", system_path);
+	 snprintf(temp, TEMPSIZE, "%s/apple_IIe.rom", system_path);
 	 if ((f = fopen(temp, "r")) == NULL) {
 	     printf("Cannot find file '%s'.\n",temp);
 	     exit(0);
@@ -1207,7 +1207,7 @@
      {
      /* load Disk II rom */
      if (!slot6_rom_loaded) {
-	 sprintf(temp, "%s/slot6.rom", system_path);
+	 snprintf(temp, TEMPSIZE, "%s/slot6.rom", system_path);
 	 if ((f = fopen( temp, "r" )) == NULL) {
 	     printf("Cannot find file '%s'.\n",temp);
 	     exit( 0 );
@@ -1343,10 +1343,10 @@
     FILE *f = NULL;
 
     /* set system defaults before user defaults. */
-    strcpy(disk_path, "./disks");
-    strcpy(system_path, "./rom");
+    strncpy(disk_path, "./disks", DISKSIZE);
+    strncpy(system_path, "./rom", SYSSIZE);
 
-    sprintf(temp, "%s/%s", getenv("HOME"), ".apple2");
+    snprintf(temp, TEMPSIZE, "%s/%s", getenv("HOME"), ".apple2");
     f = fopen(temp, "r");
     if (f == NULL) {
 	printf(
@@ -1369,7 +1369,7 @@
 void c_save_settings() {
     FILE *f = NULL;
 
-    sprintf(temp, "%s/%s", getenv("HOME"), ".apple2");
+    snprintf(temp, TEMPSIZE, "%s/%s", getenv("HOME"), ".apple2");
     f = fopen(temp, "w");
     if (f == NULL) {
 	printf(
@@ -1407,6 +1407,17 @@
     fclose(f);
 }
 
+void reload_opcodes() {
+#ifdef APPLE_IIE
+    if (apple_mode == IIE_MODE)
+        memcpy(table_opcodes,table_65c02_opcodes,1024);
+    else
+#endif
+    if (apple_mode == IIU_MODE)
+        memcpy(table_opcodes,table_6502_undoc_opcodes,1024);
+    else
+        memcpy(table_opcodes,table_6502_opcodes,1024);
+}	
 
 int main(int sargc, char *sargv[])
 {
@@ -1442,18 +1453,9 @@
 
     exception_flag = ResetSig;		/* flag reset state */
 
-    for (;;) {
-#ifdef APPLE_IIE
-	if (apple_mode == IIE_MODE)
-	    memcpy(table_opcodes,table_65c02_opcodes,1024);
-	else
-#endif
-	if (apple_mode == IIU_MODE)
-	    memcpy(table_opcodes,table_6502_undoc_opcodes,1024);
-	else
-	    memcpy(table_opcodes,table_6502_opcodes,1024);
-	
+   reload_opcodes();
 
+    for (;;) {
 	/* initialize pages */
 
         vmode_active = 0;
--- src/debugger.c
+++ src/debugger.c
@@ -358,7 +358,7 @@
 	return;
     }
 
-    while ((len = fread(temp, 1, 4096, f))) {
+    while ((len = fread(temp, 1, TEMPSIZE, f))) {
 	hexstr = temp;
 	for (; len > 0; len--) {
 	    watch_data = *hexstr;
--- src/joystick.c
+++ src/joystick.c
@@ -137,7 +137,7 @@
 	1, 22, "    center it and press a button.     " );
     c_video_refresh();
     usleep(1500000);
-    memset(temp, '\0', 512);
+    memset(temp, '\0', TEMPSIZE/8);
     c_interface_print(
 	1, 21, "                                      " );
     c_interface_print(
@@ -146,7 +146,7 @@
     almost_done = done = 0;		/* not done calibrating */
     while ((read(js_fd, &js, JS_RETURN) > 0) && (!done))
     {
-	sprintf (temp, "  x = %04x, y = %04x", js.x, js.y);
+	snprintf (temp, TEMPSIZE, "  x = %04x, y = %04x", js.x, js.y);
 	c_interface_print(1, 22, temp);
 	c_video_refresh();
 	if (js_max_x < js.x)
@@ -192,7 +192,7 @@
     printf("js_adjusthigh_y = %f\n", js_adjusthigh_y);
     printf("\n");
 
-    memset(temp, '\0', 512);
+    memset(temp, '\0', TEMPSIZE/8);
     c_interface_print(
 	1, 21, "     Press a button to continue.      " );
     c_video_refresh();
@@ -208,7 +208,7 @@
 	    ? (js.y - js_offset_y) * js_adjustlow_y
 	    : (js.y - (js_center_y/*+js_offset_y*/)) * js_adjusthigh_y +
 	    	half_joy_range;
-	sprintf(temp, "    x = %02x,   y = %02x", x_val, y_val);
+	snprintf(temp, TEMPSIZE, "    x = %02x,   y = %02x", x_val, y_val);
 	c_interface_print(1, 22, temp);
 	c_video_refresh();
     }
--- src/interface.h
+++ src/interface.h
@@ -16,7 +16,8 @@
 
 #ifndef A2_INTERFACE_H
 #define A2_INTERFACE_H
-unsigned char	disk_path[2048]/* = "./disks"*/;
+#define DISKSIZE	2048
+unsigned char	disk_path[DISKSIZE]/* = "./disks"*/;
 
 void		c_interface_print_char(int x, int y, unsigned char c);
 void		c_interface_print( int x, int y, unsigned char *s );
--- src/misc.h
+++ src/misc.h
@@ -99,8 +99,10 @@
 int		argc;
 
 /* misc arrays */
-unsigned char	system_path[ 2048 ];
-unsigned char	temp[ 4096 ];/* should be >=4096 (stuff depends on this) */
+#define SYSSIZE		2048
+#define TEMPSIZE	4096
+unsigned char	system_path[ SYSSIZE ];
+unsigned char	temp[ TEMPSIZE ];/* should be >=4096 (stuff depends on this) */
 
 
 #ifdef APPLE_IIE
@@ -143,5 +145,6 @@
 void c_save_settings();
 void c_initialize_vm();
 void c_read_random();
+void reload_opcodes();
 
 #endif
