Index: src/switch_ivr_bridge.c
===================================================================
--- src/switch_ivr_bridge.c (revision 9169)
+++ src/switch_ivr_bridge.c (revision 9170)
@@ -495,7 +495,12 @@ static switch_status_t uuid_bridge_on_so
            }
 
            if (!ready_b) {
-               switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+               const char *cid = switch_channel_get_variable(other_channel, "rdnis");
+               if (ready_a && cid) {
+                   switch_ivr_session_transfer(session, cid, NULL, NULL);
+               } else {
+                   switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+               }
            }
            switch_core_session_rwunlock(other_session);
            return SWITCH_STATUS_FALSE;
@@ -825,6 +830,7 @@ SWITCH_DECLARE(switch_status_t) switch_i
    switch_channel_t *originator_channel, *originatee_channel, *swap_channel;
    switch_status_t status = SWITCH_STATUS_FALSE;
    switch_caller_profile_t *cp, *originator_cp, *originatee_cp;
+   char *p;
 
    if ((originator_session = switch_core_session_locate(originator_uuid))) {
        if ((originatee_session = switch_core_session_locate(originatee_uuid))) {
@@ -895,6 +901,10 @@ SWITCH_DECLARE(switch_status_t) switch_i
            cp->destination_number = switch_core_strdup(cp->pool, originator_cp->caller_id_number);
            cp->caller_id_number = switch_core_strdup(cp->pool, originator_cp->caller_id_number);
            cp->caller_id_name = switch_core_strdup(cp->pool, originator_cp->caller_id_name);
+           cp->rdnis = switch_core_strdup(cp->pool, originatee_cp->destination_number);
+           if ((p = strchr(cp->rdnis, '@'))) {
+               *p = '\0';
+           }
            switch_channel_set_caller_profile(originatee_channel, cp);
            switch_channel_set_originator_caller_profile(originatee_channel, switch_caller_profile_clone(originatee_session, originator_cp));
 
@@ -902,6 +912,10 @@ SWITCH_DECLARE(switch_status_t) switch_i
            cp->destination_number = switch_core_strdup(cp->pool, originatee_cp->caller_id_number);
            cp->caller_id_number = switch_core_strdup(cp->pool, originatee_cp->caller_id_number);
            cp->caller_id_name = switch_core_strdup(cp->pool, originatee_cp->caller_id_name);
+           cp->rdnis = switch_core_strdup(cp->pool, originator_cp->destination_number);
+           if ((p = strchr(cp->rdnis, '@'))) {
+               *p = '\0';
+           }
            switch_channel_set_caller_profile(originator_channel, cp);
            switch_channel_set_originatee_caller_profile(originator_channel, switch_caller_profile_clone(originator_session, originatee_cp));
 
Index: src/mod/endpoints/mod_sofia/sofia.c
===================================================================
--- src/mod/endpoints/mod_sofia/sofia.c (revision 9169)
+++ src/mod/endpoints/mod_sofia/sofia.c (revision 9170)
@@ -1956,6 +1956,14 @@ static void sofia_handle_sip_r_invite(sw
 
        switch_channel_clear_flag(channel, CF_REQ_MEDIA);
 
+       if ((status == 180 || status == 183 || status == 200)) { 
+           if (sip->sip_user_agent && sip->sip_user_agent->g_string) {
+               switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string);
+           } else if (sip->sip_server && sip->sip_server->g_string) {
+               switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string);
+           }
+       }
+
        if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
 
            if (!switch_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
@@ -2137,14 +2145,6 @@ static void sofia_handle_sip_i_state(swi
        status = 180;
    }
 
-   if (sip && channel && (status == 180 || status == 183 || status == 200) && switch_channel_test_flag(channel, CF_OUTBOUND)) { 
-       if (sip->sip_user_agent && sip->sip_user_agent->g_string) {
-           switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string);
-       } else if (sip->sip_server && sip->sip_server->g_string) {
-           switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string);
-       }
-   }
-
    if (channel && (status == 180 || status == 183) && switch_channel_test_flag(channel, CF_OUTBOUND)) {
        const char *val;
        if ((val = switch_channel_get_variable(channel, "sip_auto_answer")) && switch_true(val)) {
@@ -3686,7 +3686,6 @@ static void sofia_info_send_sipfrag(swit
        }
    }
 }
-
 /*
  * This subroutine will take the a_params of a sip_addr_s structure and spin through them.
  * Each param will be used to create a channel variable.
