diff --git a/src/array.c b/src/array.c
index eda13830f9f9599fbcb334848631f66638029f96..c13b92ca1c009b64d230bc31a24030be89f11c1b 100644
--- a/src/array.c
+++ b/src/array.c
@@ -58,6 +58,7 @@ struct array *low_allocate_array(INT32 size,INT32 extra_space)
 
   /* for now, we don't know what will go in here */
   v->type_field=BIT_MIXED | BIT_UNFINISHED;
+  v->flags=0;
 
   v->malloced_size=size+extra_space;
   v->size=size;
@@ -770,6 +771,12 @@ void array_fix_type_field(struct array *v)
 
   t=0;
 
+  if(v->flags & ARRAY_LVALUE)
+  {
+    v->type_field=BIT_MIXED;
+    return;
+  }
+
   for(e=0; e<v->size; e++) t |= 1 << ITEM(v)[e].type;
 
 #ifdef DEBUG
@@ -788,7 +795,16 @@ void array_check_type_field(struct array *v)
 
   t=0;
 
-  for(e=0; e<v->size; e++) t |= 1 << ITEM(v)[e].type;
+  if(v->flags & ARRAY_LVALUE)
+    return;
+
+  for(e=0; e<v->size; e++)
+  {
+    if(ITEM(v)[e].type > MAX_TYPE)
+      fatal("Type is out of range.\n");
+      
+    t |= 1 << ITEM(v)[e].type;
+  }
 
   if(t & ~(v->type_field))
     fatal("Type field out of order!\n");
diff --git a/src/interpret.c b/src/interpret.c
index 4933bc51e76240f6be874c919e3b5f52b3209e76..024d2d963113c26f96d5cba803dda1f6e3662123 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: interpret.c,v 1.66 1998/02/01 04:01:32 hubbe Exp $");
+RCSID("$Id: interpret.c,v 1.67 1998/02/03 05:29:25 hubbe Exp $");
 #include "interpret.h"
 #include "object.h"
 #include "program.h"
@@ -346,10 +346,6 @@ void print_return_value(void)
   if(t_flag>3)
   {
     char *s;
-    int nonblock;
-	
-    if((nonblock=query_nonblocking(2)))
-      set_nonblocking(2,0);
 	
     init_buf();
     describe_svalue(sp-1,0,0);
@@ -363,9 +359,6 @@ void print_return_value(void)
     }
     fprintf(stderr,"-    value: %s\n",s);
     free(s);
-	
-    if(nonblock)
-      set_nonblocking(2,1);
   }
 }
 #else
@@ -560,9 +553,7 @@ static int eval_instruction(unsigned char *pc)
     if(t_flag > 2)
     {
       char *file, *f;
-      INT32 linep, nonblock;
-      if((nonblock=query_nonblocking(2)))
-	set_nonblocking(2,0);
+      INT32 linep;
 
       file=get_line(pc-1,fp->context.prog,&linep);
       while((f=STRCHR(file,'/'))) file=f+1;
@@ -572,8 +563,6 @@ static int eval_instruction(unsigned char *pc)
 	      get_f_name(instr + F_OFFSET),
 	      (long)(sp-evaluator_stack),
 	      (long)(mark_sp-mark_stack));
-      if(nonblock)
-	set_nonblocking(2,1);
     }
 
     if(instr + F_OFFSET < F_MAX_OPCODE) 
@@ -1500,6 +1489,58 @@ static int eval_instruction(unsigned char *pc)
   }
 }
 
+static void trace_return_value(void)
+{
+  char *s;
+  
+  init_buf();
+  my_strcat("Return: ");
+  describe_svalue(sp-1,0,0);
+  s=simple_free_buf();
+  if((long)strlen(s) > (long)TRACE_LEN)
+  {
+    s[TRACE_LEN]=0;
+    s[TRACE_LEN-1]='.';
+    s[TRACE_LEN-2]='.';
+    s[TRACE_LEN-2]='.';
+  }
+  fprintf(stderr,"%-*s%s\n",4,"-",s);
+  free(s);
+}
+
+static void do_trace_call(INT32 args)
+{
+  char *file,*s;
+  INT32 linep,e;
+  my_strcat("(");
+  for(e=0;e<args;e++)
+  {
+    if(e) my_strcat(",");
+    describe_svalue(sp-args+e,0,0);
+  }
+  my_strcat(")"); 
+  s=simple_free_buf();
+  if((long)strlen(s) > (long)TRACE_LEN)
+  {
+    s[TRACE_LEN]=0;
+    s[TRACE_LEN-1]='.';
+    s[TRACE_LEN-2]='.';
+    s[TRACE_LEN-2]='.';
+  }
+  if(fp && fp->pc)
+  {
+    char *f;
+    file=get_line(fp->pc,fp->context.prog,&linep);
+    while((f=STRCHR(file,'/'))) file=f+1;
+  }else{
+    linep=0;
+    file="-";
+  }
+  fprintf(stderr,"- %s:%4ld: %s\n",file,(long)linep,s);
+  free(s);
+}
+
+
 void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)
 {
   struct object *o;
@@ -1550,6 +1591,14 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)
     case T_FUNCTION:
       if(s->subtype == FUNCTION_BUILTIN)
       {
+#ifdef DEBUG
+	if(t_flag>1)
+	{
+	  init_buf();
+	  describe_svalue(s,0,0);
+	  do_trace_call(args);
+	}
+#endif
 	(*(s->u.efun->function))(args);
 	break;
       }else{
@@ -1560,10 +1609,26 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)
       break;
 
     case T_ARRAY:
+#ifdef DEBUG
+      if(t_flag>1)
+      {
+	init_buf();
+	describe_svalue(s,0,0);
+	do_trace_call(args);
+      }
+#endif
       apply_array(s->u.array,args);
       break;
 
     case T_PROGRAM:
+#ifdef DEBUG
+      if(t_flag>1)
+      {
+	init_buf();
+	describe_svalue(s,0,0);
+	do_trace_call(args);
+      }
+#endif
       push_object(clone_object(s->u.program,args));
       break;
 
@@ -1643,51 +1708,15 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)
       new_frame.context.prog->refs++;
       if(new_frame.context.parent) new_frame.context.parent->refs++;
       
-#ifdef DEBUG
       if(t_flag)
       {
-	char *file, *f;
-	INT32 linep,e,nonblock;
-	char buf[50],*s;
-	
-	if((nonblock=query_nonblocking(2)))
-	  set_nonblocking(2,0);
-	
-	if(fp && fp->pc)
-	{
-	  file=get_line(fp->pc,fp->context.prog,&linep);
-	  while((f=STRCHR(file,'/'))) file=f+1;
-	}else{
-	  linep=0;
-	  file="-";
-	}
-	
+	char buf[50];
 	init_buf();
 	sprintf(buf,"%lx->",(long)o);
 	my_strcat(buf);
 	my_strcat(function->name->str);
-	my_strcat("(");
-	for(e=0;e<args;e++)
-	{
-	  if(e) my_strcat(",");
-	  describe_svalue(sp-args+e,0,0);
-	}
-	my_strcat(")"); 
-	s=simple_free_buf();
-	if((long)strlen(s) > (long)TRACE_LEN)
-	{
-	  s[TRACE_LEN]=0;
-	  s[TRACE_LEN-1]='.';
-	  s[TRACE_LEN-2]='.';
-	  s[TRACE_LEN-2]='.';
-	}
-	fprintf(stderr,"- %s:%4ld: %s\n",file,(long)linep,s);
-	free(s);
-	
-	if(nonblock)
-	  set_nonblocking(2,1);
+	do_trace_call(args);
       }
-#endif
       
       fp = &new_frame;
       
@@ -1808,33 +1837,6 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)
 	goto apply_stack;
       }
 
-#ifdef DEBUG
-      if(t_flag)
-      {
-	char *s;
-	int nonblock;
-	
-	if((nonblock=query_nonblocking(2)))
-	  set_nonblocking(2,0);
-	
-	init_buf();
-	my_strcat("Return: ");
-	describe_svalue(sp-1,0,0);
-	s=simple_free_buf();
-	if((long)strlen(s) > (long)TRACE_LEN)
-	{
-	  s[TRACE_LEN]=0;
-	  s[TRACE_LEN-1]='.';
-	  s[TRACE_LEN-2]='.';
-	  s[TRACE_LEN-2]='.';
-	}
-	fprintf(stderr,"%-*s%s\n",4,"-",s);
-	free(s);
-	
-	if(nonblock)
-	  set_nonblocking(2,1);
-      }
-#endif
     }
   }
 
@@ -1845,7 +1847,11 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)
   }
 
   if(save_sp+1 > sp && type != APPLY_SVALUE)
+  {
     push_int(0);
+  }else{
+    if(t_flag) trace_return_value();
+  }
 }
 
 
diff --git a/src/main.c b/src/main.c
index d83f3a6dd8b571b43323965a0b998dda7c94d502..c4652581533baca45d12345c2c4dc9319b8b30d9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: main.c,v 1.39 1998/02/01 05:46:03 hubbe Exp $");
+RCSID("$Id: main.c,v 1.40 1998/02/03 05:29:26 hubbe Exp $");
 #include "fdlib.h"
 #include "backend.h"
 #include "module.h"
@@ -43,6 +43,7 @@ RCSID("$Id: main.c,v 1.39 1998/02/01 05:46:03 hubbe Exp $");
 char *master_file;
 char **ARGV;
 
+int debug_options=0;
 int d_flag=0;
 int c_flag=0;
 int t_flag=0;
@@ -183,10 +184,24 @@ int dbm_main(int argc, char **argv)
 	  break;
 
 	case 'd':
-	  if(p[1]>='0' && p[1]<='9')
-	    d_flag+=STRTOL(p+1,&p,10);
-	  else
-	    d_flag++,p++;
+	more_d_flags:
+	  switch(p[1])
+	  {
+	    case '0': case '1': case '2': case '3': case '4':
+	    case '5': case '6': case '7': case '8': case '9':
+	      d_flag+=STRTOL(p+1,&p,10);
+	      break;
+
+	    case 's':
+	      debug_options|=DEBUG_SIGNALS;
+	      p++;
+	      if(p[1]) goto more_d_flags;
+	      p++;
+	      break;
+
+	    default:
+	      d_flag++,p++;
+	  }
 	  break;
 
 	case 'a':
diff --git a/src/main.h b/src/main.h
index 54698c0a6d4520f266683ca4d1aa8fd174519369..fef26256642156d1af0aebe284f8f989b54309ad 100644
--- a/src/main.h
+++ b/src/main.h
@@ -8,7 +8,9 @@
 
 #include "callback.h"
 
-extern int d_flag, t_flag, a_flag, l_flag, c_flag, p_flag;
+extern int d_flag, t_flag, a_flag, l_flag, c_flag, p_flag, debug_options;
+
+#define DEBUG_SIGNALS 1
 
 /* Prototypes begin here */
 struct callback *add_post_master_callback(callback_func call,
diff --git a/src/object.c b/src/object.c
index ce560fa5c04caa2a87a9573ca7c47d4c73a9c01f..6aa29efd6834264c7e3f0eaafd79e0f01423a83e 100644
--- a/src/object.c
+++ b/src/object.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: object.c,v 1.36 1998/01/29 22:53:55 hubbe Exp $");
+RCSID("$Id: object.c,v 1.37 1998/02/03 05:29:27 hubbe Exp $");
 #include "object.h"
 #include "dynamic_buffer.h"
 #include "interpret.h"
@@ -470,15 +470,8 @@ void object_index_no_free2(struct svalue *to,
   {
   case T_STRING:
     f=find_shared_string_identifier(index->u.string, p);
-    free_string(index->u.string);
-    index->type=T_LVALUE;
-    index->u.integer=f;
     break;
-    
-  case T_LVALUE:
-    f=index->u.integer;
-    break;
-      
+
   default:
     error("Lookup on non-string value.\n");
   }
@@ -574,13 +567,6 @@ void object_set_index2(struct object *o,
     f=find_shared_string_identifier(index->u.string, p);
     if(f<0)
       error("No such variable (%s) in object.\n", index->u.string->str);
-    free_string(index->u.string);
-    index->type=T_LVALUE;
-    index->u.integer=f;
-    break;
-
-  case T_LVALUE:
-    f=index->u.integer;
     break;
 
   default:
@@ -676,13 +662,6 @@ union anything *object_get_item_ptr(struct object *o,
   {
   case T_STRING:
     f=find_shared_string_identifier(index->u.string, p);
-    free_string(index->u.string);
-    index->type=T_LVALUE;
-    index->u.integer=f;
-    break;
-
-  case T_LVALUE:
-    f=index->u.integer;
     break;
 
   default:
diff --git a/src/signal_handler.c b/src/signal_handler.c
index cd98e0e7312aa72c696e2d3c119e5725f2038a90..ae3e464c0047a99a8e03ae0dff6af6dd71ca77aa 100644
--- a/src/signal_handler.c
+++ b/src/signal_handler.c
@@ -272,9 +272,8 @@ static struct sigdesc signal_desc []={
   { -1, "END" } /* Notused */
 };
 
-typedef RETSIGTYPE (*sigfunctype) (int);
 
-static void my_signal(int sig, sigfunctype fun)
+void my_signal(int sig, sigfunctype fun)
 {
 #ifdef HAVE_SIGACTION
   {
@@ -1255,6 +1254,14 @@ static void f_ualarm(INT32 args)
 }
 #endif
 
+#ifdef DEBUG
+static RETSIGTYPE fatal_signal(int signum)
+{
+  my_signal(signum,SIG_DFL);
+  fatal("Fatal signal (%s) recived.\n",signame(signum));
+}
+#endif
+
 void init_signals(void)
 {
   int e;
@@ -1267,6 +1274,15 @@ void init_signals(void)
   my_signal(SIGPIPE, SIG_IGN);
 #endif
 
+#ifdef DEBUG
+#ifdef SIGSEGV
+  my_signal(SIGSEGV, fatal_signal);
+#endif
+#ifdef SIGBUS
+  my_signal(SIGBUS, fatal_signal);
+#endif
+#endif
+
   for(e=0;e<MAX_SIGNALS;e++)
     signal_callbacks[e].type=T_INT;
 
diff --git a/src/signal_handler.h b/src/signal_handler.h
index 4436a1ecc5e9547bd0d030f2b9d93b70148b9afb..61e8454dab48631db2055f123978b64d9af34638 100644
--- a/src/signal_handler.h
+++ b/src/signal_handler.h
@@ -6,9 +6,12 @@
 #ifndef SIGNAL_H
 #define SIGNAL_H
 
+typedef RETSIGTYPE (*sigfunctype) (int);
+
 /* Prototypes begin here */
 struct wait_data;
 struct sigdesc;
+void my_signal(int sig, sigfunctype fun);
 struct pid_status;
 void f_create_process(INT32 args);
 void f_fork(INT32 args);
diff --git a/src/svalue.c b/src/svalue.c
index a772c1f9c28fdbd80c9c5cc06bcd61f771fd6c8f..7fb2807df96e73bb9cdd867b28a341e3e066e646 100644
--- a/src/svalue.c
+++ b/src/svalue.c
@@ -153,6 +153,59 @@ void free_svalues(struct svalue *s,INT32 num, INT32 type_hint)
     DOTYPE(BIT_OBJECT, free_object, object);
     DOTYPE(BIT_PROGRAM, free_program, program);
 
+#define COMBINE9(A) case A:
+
+#define COMBINE8(A,B) \
+  COMBINE9(A|B)
+
+#define COMBINE7(A,B,C) \
+  COMBINE8(A|B,C) \
+  COMBINE9(A|C)
+
+#define COMBINE6(A,B,C,D) \
+  COMBINE7(A|B,C,D) \
+  COMBINE8(A|C,D) \
+  COMBINE9(A|D)
+
+#define COMBINE5(A,B,C,D,E) \
+  COMBINE6(A|B,C,D,E) \
+  COMBINE7(A|C,D,E) \
+  COMBINE8(A|D,E) \
+  COMBINE9(A|E)
+
+#define COMBINE4(A,B,C,D,E,F) \
+  COMBINE5(A|B,C,D,E,F) \
+  COMBINE6(A|C,D,E,F) \
+  COMBINE7(A|D,E,F) \
+  COMBINE8(A|E,F) \
+  COMBINE9(A|F)
+
+#define COMBINE3(A,B,C,D,E,F,G) \
+  COMBINE4(A|B,C,D,E,F,G) \
+  COMBINE5(A|C,D,E,F,G) \
+  COMBINE6(A|D,E,F,G) \
+  COMBINE7(A|E,F,G) \
+  COMBINE8(A|F,G) \
+  COMBINE9(A|G)
+
+#define COMBINE(A,B,C,D,E,F,G) \
+  COMBINE3(A,B,C,D,E,F,G) \
+  COMBINE4(B,C,D,E,F,G) \
+  COMBINE5(C,D,E,F,G) \
+  COMBINE6(D,E,F,G) \
+  COMBINE7(E,F,G) \
+  COMBINE8(F,G)
+
+
+  COMBINE(BIT_STRING, BIT_ARRAY, BIT_MAPPING, BIT_MULTISET, BIT_OBJECT, BIT_PROGRAM, BIT_FUNCTION);
+    while(--num>=0)
+    {
+      if(s->u.refs[0]--<=0)
+	really_free_svalue(s);
+      s++;
+    }
+    break;
+
   case BIT_FUNCTION:
     while(--num>=0)
     {