diff -Naur modules/tm_orig/config.h modules/tm_patch/config.h
--- modules/tm_orig/config.h	2008-04-23 15:48:33.000000000 +0200
+++ modules/tm_patch/config.h	2008-04-23 15:42:12.000000000 +0200
@@ -81,4 +81,6 @@
 /* FIFO substitution character */
 #define SUBST_CHAR '!'
 
+#define EXTRA_BRANCH 1
+
 #endif
diff -Naur modules/tm_orig/t_cancel.c modules/tm_patch/t_cancel.c
--- modules/tm_orig/t_cancel.c	2008-04-23 15:48:44.000000000 +0200
+++ modules/tm_patch/t_cancel.c	2008-04-23 15:41:38.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $Id: t_cancel.c,v 1.1 2008/02/25 11:33:50 zappasod Exp $
+ * $Id: t_cancel.c 2943 2007-10-19 15:15:01Z anca_vamanu $
  *
  * Copyright (C) 2001-2003 FhG Fokus
  *
@@ -49,10 +49,22 @@
 void which_cancel( struct cell *t, branch_bm_t *cancel_bm )
 {
 	int i;
+#ifdef EXTRA_BRANCH
+	int idx;
+	idx=0;
+#endif //EXTRA_BRANCH
 
 	for( i=t->first_branch ; i<t->nr_of_outgoings ; i++ ) {
+#ifdef EXTRA_BRANCH
+		if(i!=0 && i%32==0)
+			idx++;
+#endif //EXTRA_BRANCH
 		if (should_cancel_branch(t, i)) 
+#ifdef EXTRA_BRANCH
+			(*cancel_bm)[idx] |= 1<<(i%32) ;
+#else
 			*cancel_bm |= 1<<i ;
+#endif //EXTRA_BRANCH
 
 	}
 }
@@ -62,11 +74,24 @@
 void cancel_uacs( struct cell *t, branch_bm_t cancel_bm )
 {
 	int i;
+#ifdef EXTRA_BRANCH
+	int idx;
+	idx=0;
+#endif //EXTRA_BRANCH
 
 	/* cancel pending client transactions, if any */
 	for( i=0 ; i<t->nr_of_outgoings ; i++ ) 
+#ifdef EXTRA_BRANCH
+	{
+		if(i!=0 && i%32==0)
+			idx++;
+		if (cancel_bm[idx] & (1<<(i%32)))
+			cancel_branch(t, i);
+	}
+#else
 		if (cancel_bm & (1<<i))
 			cancel_branch(t, i);
+#endif //EXTRA_BRANCH
 }
 
 
diff -Naur modules/tm_orig/t_fwd.c modules/tm_patch/t_fwd.c
--- modules/tm_orig/t_fwd.c	2008-04-23 15:48:51.000000000 +0200
+++ modules/tm_patch/t_fwd.c	2008-04-23 15:41:44.000000000 +0200
@@ -538,8 +538,12 @@
 	int lowest_error;
 
 	lowest_error=0;
+#ifdef EXTRA_BRANCH
+	for(i=0;i<NEXTRA_BRANCH;i++)
+		cancel_bitmap[i]=0;
+#else
 	cancel_bitmap=0;
-
+#endif //EXTRA_BRANCH
 	/* send back 200 OK as per RFC3261 */
 	reason.s = CANCELING;
 	reason.len = sizeof(CANCELING)-1;
@@ -587,6 +591,10 @@
 	int idx;
 	str path;
 	str bk_path;
+#ifdef EXTRA_BRANCH
+	int id_br;
+	id_br=0;
+#endif //EXTRA_BRANCH
 
 	/* make -Wall happy */
 	current_uri.s=0;
@@ -617,7 +625,13 @@
 	/* if no more specific error code is known, use this */
 	lowest_ret=E_BUG;
 	/* branches added */
+#ifdef EXTRA_BRANCH
+	for(id_br=0;id_br<NEXTRA_BRANCH;id_br++)
+		added_branches[id_br]=0;
+	id_br=0;
+#else	
 	added_branches=0;
+#endif //EXTRA_BRANCH
 	/* branch to begin with */
 	t->first_branch=t->nr_of_outgoings;
 
@@ -630,11 +644,23 @@
 		branch_ret = add_uac( t, p_msg, &current_uri, &backup_dst, 
 				&p_msg->path_vec, proxy);
 		if (branch_ret>=0)
+#ifdef EXTRA_BRANCH
+		{
+			if(branch_ret!=0 && branch_ret%32==0)
+				id_br++;
+			added_branches[id_br] |= 1<<(branch_ret%32);
+		}
+#else	
 			added_branches |= 1<<branch_ret;
+#endif //EXTRA_BRANCH
 		else
 			lowest_ret=branch_ret;
 	} else try_new=0;
 
+#ifdef EXTRA_BRANCH
+	id_br=0;
+#endif //EXTRA_BRANCH
+
 	for( idx=0; (current_uri.s=get_branch( idx, &current_uri.len, &q,
 	&dst_uri, &path, &br_flags, &p_msg->force_send_socket))!=0 ; idx++ ) {
 		try_new++;
@@ -645,7 +671,15 @@
 		   any other algorithm which picks any other negative
 		   branch result */
 		if (branch_ret>=0) 
+#ifdef EXTRA_BRANCH
+		{
+			if(branch_ret!=0 && branch_ret%32==0)
+				id_br++;
+			added_branches[id_br] |= 1<<(branch_ret%32);
+		}
+#else	
 			added_branches |= 1<<branch_ret;
+#endif //EXTRA_BRANCH
 		else
 			lowest_ret=branch_ret;
 	}
@@ -665,7 +699,15 @@
 	t->uas.request->flags = p_msg->flags;
 
 	/* things went wrong ... no new branch has been fwd-ed at all */
+#ifdef EXTRA_BRANCH
+	i=0;
+	for(id_br=0;id_br<NEXTRA_BRANCH;id_br++)
+		if(added_branches[id_br]!=0)
+			i++;
+	if (i==0) {
+#else	
 	if (added_branches==0) {
+#endif //EXTRA_BRANCH
 		if (try_new==0) {
 			ser_error = E_NO_DESTINATION;
 			LM_ERR("no branch for forwarding\n");
@@ -678,8 +720,18 @@
 
 	/* send them out now */
 	success_branch=0;
+#ifdef EXTRA_BRANCH
+	id_br=0;
+#endif //EXTRA_BRANCH
+
 	for (i=t->first_branch; i<t->nr_of_outgoings; i++) {
+#ifdef EXTRA_BRANCH
+		if(i!=0 && i%32==0)
+			id_br++;
+		if (added_branches[id_br] & (1<<(i%32))) {
+#else	
 		if (added_branches & (1<<i)) {
+#endif //EXTRA_BRANCH
 			do {
 				if (check_blacklists( t->uac[i].request.dst.proto,
 				&t->uac[i].request.dst.to,
diff -Naur modules/tm_orig/timer.c modules/tm_patch/timer.c
--- modules/tm_orig/timer.c	2008-04-23 15:48:58.000000000 +0200
+++ modules/tm_patch/timer.c	2008-04-23 15:41:31.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $Id: timer.c,v 1.1 2008/02/25 11:43:28 zappasod Exp $
+ * $Id: timer.c 2943 2007-10-19 15:15:01Z anca_vamanu $
  *
  * Copyright (C) 2001-2003 FhG Fokus
  * Copyright (C) 2007 Voice Sistem SRL
@@ -246,10 +246,21 @@
 	branch_bm_t cancel_bitmap;
 	short do_cancel_branch;
 	enum rps reply_status;
+#ifdef EXTRA_BRANCH
+	int idx;
+#endif //EXTRA_BRANCH
 
 	do_cancel_branch = is_invite(t) && should_cancel_branch(t, branch);
 
+#ifdef EXTRA_BRANCH
+	idx=0;
+	if(branch!=0 && branch%32==0)
+		idx++;
+	cancel_bitmap[idx]=do_cancel_branch ? 1<<(branch%32) : 0;
+#else
 	cancel_bitmap=do_cancel_branch ? 1<<branch : 0;
+#endif //EXTRA_BRANCH
+	
 	if ( is_local(t) ) {
 		reply_status=local_reply( t, FAKED_REPLY, branch, 
 					  code, &cancel_bitmap );
diff -Naur modules/tm_orig/tm.c modules/tm_patch/tm.c
--- modules/tm_orig/tm.c	2008-04-23 15:49:04.000000000 +0200
+++ modules/tm_patch/tm.c	2008-04-23 15:41:11.000000000 +0200
@@ -532,7 +532,11 @@
 
 	/* checking if we have sufficient bitmap capacity for given
 	   maximum number of  branches */
+#ifdef EXTRA_BRANCH
+	if (MAX_BRANCHES+1>(NEXTRA_BRANCH*32)-1) {
+#else
 	if (MAX_BRANCHES+1>31) {
+#endif //EXTRA_BRANCH
 		LM_CRIT("Too many max UACs for UAC branch_bm_t bitmap: %d\n",
 			MAX_BRANCHES );
 		return -1;
diff -Naur modules/tm_orig/t_reply.c modules/tm_patch/t_reply.c
--- modules/tm_orig/t_reply.c	2008-04-23 16:06:06.000000000 +0200
+++ modules/tm_patch/t_reply.c	2008-04-23 15:41:24.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $Id: t_reply.c,v 1.1 2008/02/25 11:34:41 zappasod Exp $
+ * $Id: t_reply.c,v 1.2 2008/03/12 09:22:41 zappasod Exp $
  *
  * Copyright (C) 2001-2003 FhG Fokus
  *
@@ -305,6 +305,9 @@
 	unsigned int buf_len;
 	branch_bm_t cancel_bitmap;
 	str cb_s;
+#ifdef EXTRA_BRANCH
+	int i;
+#endif //EXTRA_BRANCH
 
 	if (!buf)
 	{
@@ -319,7 +322,12 @@
 		goto error;
 	}
 
+#ifdef EXTRA_BRANCH
+	for(i=0;i<NEXTRA_BRANCH;i++)
+		cancel_bitmap[i]=0;
+#else
 	cancel_bitmap=0;
+#endif //EXTRA_BRANCH
 	if (lock) LOCK_REPLIES( trans );
 	if ( is_invite(trans) ) which_cancel(trans, &cancel_bitmap );
 	if (trans->uas.status>=200) {
@@ -520,10 +528,9 @@
 	return 0;
 }
 
+
 inline static void free_faked_req(struct sip_msg *faked_req, struct cell *t)
 {
-	struct hdr_field *hdr;
-
 	if (faked_req->new_uri.s) {
 		pkg_free(faked_req->new_uri.s);
 		faked_req->new_uri.s = 0;
@@ -534,18 +541,7 @@
 	del_notflaged_lumps( &(faked_req->body_lumps), LUMPFLAG_SHMEM );
 	del_nonshm_lump_rpl( &(faked_req->reply_lump) );
 
-	/* free header's parsed structures that were added by failure handlers */
-	for( hdr=faked_req->headers ; hdr ; hdr=hdr->next ) {
-		if ( hdr->parsed && hdr_allocs_parse(hdr) &&
-		(hdr->parsed<(void*)t->uas.request ||
-		hdr->parsed>=(void*)t->uas.end_request)) {
-			/* header parsed filed doesn't point inside uas.request memory
-			 * chunck -> it was added by failure funcs.-> free it as pkg */
-			LM_DBG("removing hdr->parsed %d\n",	hdr->type);
-			clean_hdr_field(hdr);
-			hdr->parsed = 0;
-		}
-	}
+	clean_msg_clone( faked_req, t->uas.request, t->uas.end_request);
 }
 
 
@@ -796,6 +792,8 @@
 			/* this is a winner and close all branches */
 			which_cancel( Trans, cancel_bitmap );
 			picked_branch=branch;
+			/* no more new branches should be added to this transaction */
+			Trans->flags |= T_NO_NEW_BRANCHES_FLAG;
 		} else {
 			/* if all_final return lowest */
 			picked_branch = t_pick_branch( Trans, &picked_code);
@@ -1205,6 +1203,9 @@
 	struct sip_msg *winning_msg;
 	int winning_code;
 	int totag_retr;
+#ifdef EXTRA_BRANCH
+	int i;
+#endif //EXTRA_BRANCH
 	/* branch_bm_t cancel_bitmap; */
 
 	/* keep warning 'var might be used un-inited' silent */	
@@ -1212,7 +1213,12 @@
 	winning_code=0;
 	totag_retr=0;
 
+#ifdef EXTRA_BRANCH
+	for(i=0;i<NEXTRA_BRANCH;i++)
+		*cancel_bitmap[i]=0;
+#else
 	*cancel_bitmap=0;
+#endif //EXTRA_BRANCH
 
 	reply_status=t_should_relay_response( t, msg_status, branch,
 		&local_store, &local_winner, cancel_bitmap, p_msg );
@@ -1289,6 +1295,10 @@
 	struct ua_client *uac;
 	struct cell *t;
 	struct usr_avp **backup_list;
+#ifdef EXTRA_BRANCH
+	int i;
+#endif //EXTRA_BRANCH
+	
 
 	/* make sure we know the associated transaction ... */
 	if (t_check(p_msg, &branch ) == -1) goto not_found;
@@ -1297,7 +1307,12 @@
 	t = get_t();
 	if ((t == 0) || (t == T_UNDEFINED)) goto not_found;
 
+#ifdef EXTRA_BRANCH
+	for(i=0;i<NEXTRA_BRANCH;i++)
+		cancel_bitmap[i]=0;
+#else
 	cancel_bitmap=0;
+#endif //EXTRA_BRANCH
 	msg_status=p_msg->REPLY_STATUS;
 
 	uac=&t->uac[branch];
diff -Naur modules/tm_orig/t_reply.h modules/tm_patch/t_reply.h
--- modules/tm_orig/t_reply.h	2008-04-23 15:49:18.000000000 +0200
+++ modules/tm_patch/t_reply.h	2008-04-23 15:42:27.000000000 +0200
@@ -56,7 +56,12 @@
 int unmatched_totag(struct cell *t, struct sip_msg *ack);
 
 /* branch bitmap type */
+#ifdef EXTRA_BRANCH
+#define NEXTRA_BRANCH		2
+typedef unsigned int branch_bm_t[NEXTRA_BRANCH];
+#else
 typedef unsigned int branch_bm_t;
+#endif //EXTRA_BRANCH
 
 /* reply export types */
 typedef int (*treply_f)(struct sip_msg * , unsigned int , str * );
