Index: pjproject/trunk/pjlib/src/pj/config.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/config.c	(revision 421)
+++ pjproject/trunk/pjlib/src/pj/config.c	(revision 422)
@@ -22,5 +22,5 @@
 
 static const char *id = "config.c";
-const char *PJ_VERSION = "0.5.4.12";
+const char *PJ_VERSION = "0.5.4.13";
 
 PJ_DEF(void) pj_dump_config(void)
Index: pjproject/trunk/pjsip-apps/src/pjsua/main.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/main.c	(revision 421)
+++ pjproject/trunk/pjsip-apps/src/pjsua/main.c	(revision 422)
@@ -414,4 +414,10 @@
     struct input_result result;
 
+
+    /* If user specifies URI to call, then call the URI */
+    if (pjsua.uri_to_call.slen) {
+	pjsua_make_call( current_acc, pjsua.uri_to_call.ptr, NULL);
+    }
+
     keystroke_help();
 
Index: pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 421)
+++ pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 422)
@@ -184,6 +184,4 @@
     pjmedia_endpt   *med_endpt;	    /**< Media endpoint.		*/
     unsigned	     clock_rate;    /**< Internal clock rate.		*/
-    pj_bool_t	     has_wb;	    /**< Include wideband codecs	*/
-    pj_bool_t	     has_uwb;	    /**< Include ultra-wideband codecs	*/
     pjmedia_conf    *mconf;	    /**< Media conference.		*/
     pj_bool_t	     null_audio;    /**< Null audio flag.		*/
@@ -250,4 +248,5 @@
 
     /* PJSUA Calls: */
+    pj_str_t	     uri_to_call;   /**< URI to call.			*/
     int		     max_calls;	    /**< Max nb of calls.		*/
     int		     call_cnt;	    /**< Number of calls.		*/
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 421)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 422)
@@ -1048,11 +1048,12 @@
 				   call->conf_slot, 0);
 
-    } else if (pjsua.auto_loop && call->inv->role == PJSIP_ROLE_UAS) {
+    }
+    if (pjsua.auto_loop && call->inv->role == PJSIP_ROLE_UAS) {
 
 	pjmedia_conf_connect_port( pjsua.mconf, call->conf_slot, 
 				   call->conf_slot, 0);
 
-    } else if (pjsua.auto_conf) {
-
+    }
+    if (pjsua.auto_conf) {
 	int i;
 
@@ -1071,9 +1072,12 @@
 	}
 
-    } else {
-
-	/* Connect new call to the sound device port (port zero) in the
-	 * main conference bridge.
-	 */
+    } 
+    
+    /* Normal operation: if no auto_xx is given, connect new call to 
+     * the sound device port (port zero) in the main conference bridge.
+     */
+    if (pjsua.auto_play == 0 && pjsua.auto_loop == 0 &&
+	pjsua.auto_conf == 0)
+    {
 	pjmedia_conf_connect_port( pjsua.mconf, 0, call->conf_slot, 0);
 	pjmedia_conf_connect_port( pjsua.mconf, call->conf_slot, 0, 0);
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 421)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 422)
@@ -80,11 +80,7 @@
 #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
     pjsua.clock_rate = 44100;
-#else
-    pjsua.clock_rate = 8000;
 #endif
     pjsua.complexity = -1;
     pjsua.quality = 4;
-    pjsua.has_wb = 0;
-    pjsua.has_uwb = 0;
 
 
@@ -621,174 +617,91 @@
 static pj_status_t init_media(void)
 {
+    int i;
     unsigned options;
+    unsigned clock_rate;
+    unsigned samples_per_frame;
+    pj_str_t codec_id;
     pj_status_t status;
 
-    /* If user doesn't specify any codecs, register all of them. */
-    if (pjsua.codec_cnt == 0) {
-
+    /* Register all codecs */
 #if PJMEDIA_HAS_SPEEX_CODEC
-	unsigned option = PJMEDIA_SPEEX_NO_WB | PJMEDIA_SPEEX_NO_UWB;
-
-	/* Register speex. */
-	if (pjsua.has_wb)
-	    option &= ~PJMEDIA_SPEEX_NO_WB;
-	if (pjsua.has_uwb)
-	    option &= ~PJMEDIA_SPEEX_NO_UWB;
-
-	status = pjmedia_codec_speex_init(pjsua.med_endpt, option, 
-					  pjsua.quality, pjsua.complexity );
-	if (status != PJ_SUCCESS) {
-	    pjsua_perror(THIS_FILE, "Error initializing Speex codec",
-		         status);
-	    return status;
-	}
-
-	pjsua.codec_arg[pjsua.codec_cnt] = pj_str("speex");
-	pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_speex_deinit;
-	pjsua.codec_cnt++;
+    /* Register speex. */
+    status = pjmedia_codec_speex_init(pjsua.med_endpt, 
+				      PJMEDIA_SPEEX_NO_UWB,
+				      pjsua.quality, pjsua.complexity );
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Error initializing Speex codec",
+		     status);
+	return status;
+    }
+
+    /* Set "speex/16000/1" to have highest priority */
+    codec_id = pj_str("speex/16000/1");
+    pjmedia_codec_mgr_set_codec_priority( 
+	pjmedia_endpt_get_codec_mgr(pjsua.med_endpt),
+	&codec_id, 
+	PJMEDIA_CODEC_PRIO_HIGHEST);
+
 #endif /* PJMEDIA_HAS_SPEEX_CODEC */
 
 #if PJMEDIA_HAS_GSM_CODEC
-	/* Register GSM */
-	status = pjmedia_codec_gsm_init(pjsua.med_endpt);
-	if (status != PJ_SUCCESS) {
-	    pjsua_perror(THIS_FILE, "Error initializing GSM codec",
-		         status);
-	    return status;
-	}
-
-	pjsua.codec_arg[pjsua.codec_cnt] = pj_str("gsm");
-	pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_gsm_deinit;
-	pjsua.codec_cnt++;
+    /* Register GSM */
+    status = pjmedia_codec_gsm_init(pjsua.med_endpt);
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Error initializing GSM codec",
+		     status);
+	return status;
+    }
 #endif /* PJMEDIA_HAS_GSM_CODEC */
 
+#if PJMEDIA_HAS_G711_CODEC
+    /* Register PCMA and PCMU */
+    status = pjmedia_codec_g711_init(pjsua.med_endpt);
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Error initializing G711 codec",
+		     status);
+	return status;
+    }
+#endif	/* PJMEDIA_HAS_G711_CODEC */
+
 #if PJMEDIA_HAS_L16_CODEC
-	/* Register L16 */
-	status = pjmedia_codec_l16_init(pjsua.med_endpt, 0);
-	if (status != PJ_SUCCESS) {
-	    pjsua_perror(THIS_FILE, "Error initializing L16 codec",
-		         status);
-	    return status;
-	}
-
-	pjsua.codec_arg[pjsua.codec_cnt] = pj_str("l16");
-	pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_l16_deinit;
-	pjsua.codec_cnt++;
-#endif /* PJMEDIA_HAS_L16_CODEC */
-
-
-#if PJMEDIA_HAS_G711_CODEC
-	/* Register PCMA and PCMU */
-	status = pjmedia_codec_g711_init(pjsua.med_endpt);
-	if (status != PJ_SUCCESS) {
-	    pjsua_perror(THIS_FILE, "Error initializing G711 codec",
-		         status);
-	    return status;
-	}
-
-	pjsua.codec_arg[pjsua.codec_cnt] = pj_str("pcmu");
-	pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_g711_deinit;
-	pjsua.codec_cnt++;
-	pjsua.codec_arg[pjsua.codec_cnt] = pj_str("pcma");
-	pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_g711_deinit;
-	pjsua.codec_cnt++;
-#endif	/* PJMEDIA_HAS_G711_CODEC */
-
-    } else {
-
-	/* If user specifies the exact codec to be used, then create only
-	 * those codecs.
-	 */
-	int i;
-
-	for (i=0; i<pjsua.codec_cnt; ++i) {
+    /* Register L16 family codecs, but disable all */
+    status = pjmedia_codec_l16_init(pjsua.med_endpt, 0);
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Error initializing L16 codecs",
+		     status);
+	return status;
+    }
+
+    /* Disable ALL L16 codecs */
+    codec_id = pj_str("L16");
+    pjmedia_codec_mgr_set_codec_priority( 
+	pjmedia_endpt_get_codec_mgr(pjsua.med_endpt),
+	&codec_id, 
+	PJMEDIA_CODEC_PRIO_DISABLED);
+
+#endif	/* PJMEDIA_HAS_L16_CODEC */
+
+
+    /* If user specifies the exact codec to be used, then disable all codecs
+     * and only enable those specific codecs.
+     */
+    if (pjsua.codec_cnt != 0) {
+	codec_id = pj_str("");
+	pjmedia_codec_mgr_set_codec_priority( 
+	    pjmedia_endpt_get_codec_mgr(pjsua.med_endpt),
+	    &codec_id, 
+	    PJMEDIA_CODEC_PRIO_DISABLED);
+    }
+
 	
-	    if (0) {
-		/* Dummy */
-	    }
-#if PJMEDIA_HAS_SPEEX_CODEC
-	    /* Is it speex? */
-	    else if (!pj_stricmp2(&pjsua.codec_arg[i], "speex")) {
-
-		unsigned option = PJMEDIA_SPEEX_NO_WB | PJMEDIA_SPEEX_NO_UWB;
-
-		/* Register speex. */
-		if (pjsua.has_wb)
-		    option &= ~(PJMEDIA_SPEEX_NO_WB);
-		if (pjsua.has_uwb)
-		    option &= ~(PJMEDIA_SPEEX_NO_UWB);
-
-		status = pjmedia_codec_speex_init(pjsua.med_endpt, option,
-						  -1, -1);
-		if (status != PJ_SUCCESS) {
-		    pjsua_perror(THIS_FILE, "Error initializing Speex codec",
-			         status);
-		    return status;
-		}
-
-		pjsua.codec_deinit[i] = &pjmedia_codec_speex_deinit;
-	    }
-#endif	/* PJMEDIA_HAS_SPEEX_CODEC */
-
-#if PJMEDIA_HAS_GSM_CODEC
-	    /* Is it gsm? */
-	    else if (!pj_stricmp2(&pjsua.codec_arg[i], "gsm")) {
-
-		status = pjmedia_codec_gsm_init(pjsua.med_endpt);
-		if (status != PJ_SUCCESS) {
-		    pjsua_perror(THIS_FILE, "Error initializing GSM codec",
-			         status);
-		    return status;
-		}
-
-		pjsua.codec_deinit[i] = &pjmedia_codec_gsm_deinit;
-
-	    }
-#endif	/* PJMEDIA_HAS_GSM_CODEC */
-
-#if PJMEDIA_HAS_L16_CODEC
-	    /* Is it l16? */
-	    else if (!pj_stricmp2(&pjsua.codec_arg[i], "l16")) {
-
-		status = pjmedia_codec_l16_init(pjsua.med_endpt, 0);
-		if (status != PJ_SUCCESS) {
-		    pjsua_perror(THIS_FILE, "Error initializing L16 codec",
-			         status);
-		    return status;
-		}
-
-		pjsua.codec_deinit[i] = &pjmedia_codec_l16_deinit;
-
-		pjsua.clock_rate = 44100;
-	    }
-#endif	/* PJMEDIA_HAS_L16_CODEC */
-
-#if PJMEDIA_HAS_G711_CODEC
-	    /* Is it pcma/pcmu? */
-	    else if (!pj_stricmp2(&pjsua.codec_arg[i], "pcmu") ||
-		     !pj_stricmp2(&pjsua.codec_arg[i], "pcma"))
-	    {
-
-		status = pjmedia_codec_g711_init(pjsua.med_endpt);
-		if (status != PJ_SUCCESS) {
-		    pjsua_perror(THIS_FILE, "Error initializing G711 codec",
-			         status);
-		    return status;
-		}
-
-		pjsua.codec_deinit[i] = &pjmedia_codec_g711_deinit;
-
-	    }
-#endif	/* PJMEDIA_HAS_G711_CODEC */
-
-	    /* Don't know about this codec... */
-	    else {
-
-		PJ_LOG(1,(THIS_FILE, "Error: unsupported codecs %s",
-			  pjsua.codec_arg[i].ptr));
-		return PJMEDIA_CODEC_EUNSUP;
-	    }
-	}
-    }
+
+    for (i=0; i<pjsua.codec_cnt; ++i) {
+	pjmedia_codec_mgr_set_codec_priority( 
+	    pjmedia_endpt_get_codec_mgr(pjsua.med_endpt),
+	    &pjsua.codec_arg[i], 
+	    PJMEDIA_CODEC_PRIO_NEXT_HIGHER);
+    }
+
 
     /* Init options for conference bridge. */
@@ -798,10 +711,12 @@
 
     /* Init conference bridge. */
-
+    clock_rate = pjsua.clock_rate ? pjsua.clock_rate : 16000;
+    samples_per_frame = clock_rate * 20 / 1000;
     status = pjmedia_conf_create(pjsua.pool, 
 				 pjsua.max_calls+PJSUA_CONF_MORE_PORTS, 
-				 pjsua.clock_rate, 
+				 clock_rate, 
 				 1, /* mono */
-				 pjsua.clock_rate * 20 / 1000, 16, 
+				 samples_per_frame, 
+				 16, 
 				 options,
 				 &pjsua.mconf);
@@ -814,7 +729,7 @@
 
     /* Add NULL port to the bridge. */
-    status = pjmedia_null_port_create( pjsua.pool, pjsua.clock_rate, 
+    status = pjmedia_null_port_create( pjsua.pool, clock_rate, 
 				       1, /* mono */
-				       pjsua.clock_rate * 20 / 1000, 16,
+				       samples_per_frame, 16,
 				       &pjsua.null_port);
     pjmedia_conf_add_port( pjsua.mconf, pjsua.pool, pjsua.null_port, 
@@ -1128,7 +1043,19 @@
 
     /* Shutdown all codecs: */
-    for (i = pjsua.codec_cnt-1; i >= 0; --i) {
-	(*pjsua.codec_deinit[i])();
-    }
+#if PJMEDIA_HAS_SPEEX_CODEC
+    pjmedia_codec_speex_deinit();
+#endif /* PJMEDIA_HAS_SPEEX_CODEC */
+
+#if PJMEDIA_HAS_GSM_CODEC
+    pjmedia_codec_gsm_deinit();
+#endif /* PJMEDIA_HAS_GSM_CODEC */
+
+#if PJMEDIA_HAS_G711_CODEC
+    pjmedia_codec_g711_deinit();
+#endif	/* PJMEDIA_HAS_G711_CODEC */
+
+#if PJMEDIA_HAS_L16_CODEC
+    pjmedia_codec_l16_deinit();
+#endif	/* PJMEDIA_HAS_L16_CODEC */
 
     /* Destroy media endpoint. */
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c	(revision 421)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c	(revision 422)
@@ -84,6 +84,5 @@
     puts  ("");
     puts  ("Media Options:");
-    puts  ("  --wb                Enable wideband codecs and set clock-rate to 16KHz");
-    puts  ("  --uwb               Enable ultra-wideband codecs and set clock-rate to 32KHz");
+    puts  ("  --add-codec=name    Manually add codec (default is to enable all)");
     puts  ("  --clock-rate=N      Override sound device clock rate");
     puts  ("  --null-audio        Use NULL audio device");
@@ -94,5 +93,4 @@
     puts  ("  --auto-conf         Automatically put incoming calls to conference");
     puts  ("  --rtp-port=N        Base port to try for RTP (default=4000)");
-    puts  ("  --add-codec=name    Specify alternate codec order");
     puts  ("  --complexity=N      Specify encoding complexity (0-10, default=none(-1))");
     puts  ("  --quality=N         Specify encoding quality (0-10, default=4)");
@@ -159,5 +157,5 @@
     fhnd = fopen(filename, "rt");
     if (!fhnd) {
-	printf("Unable to open config file %s\n", filename);
+	PJ_LOG(1,(THIS_FILE, "Unable to open config file %s", filename));
 	fflush(stdout);
 	return -1;
@@ -192,5 +190,6 @@
 
     if (argc == MAX_ARGS && (i!=*app_argc || !feof(fhnd))) {
-	printf("Too many arguments specified in cmd line/config file\n");
+	PJ_LOG(1,(THIS_FILE, 
+		  "Too many arguments specified in cmd line/config file"));
 	fflush(stdout);
 	fclose(fhnd);
@@ -228,5 +227,5 @@
 	   OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP,
 	   OPT_AUTO_CONF, OPT_CLOCK_RATE,
-	   OPT_PLAY_FILE, OPT_WB, OPT_UWB, OPT_RTP_PORT, OPT_ADD_CODEC,
+	   OPT_PLAY_FILE, OPT_RTP_PORT, OPT_ADD_CODEC,
 	   OPT_COMPLEXITY, OPT_QUALITY,
 	   OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, OPT_UAS_REFRESH,
@@ -240,6 +239,4 @@
 	{ "help",	0, 0, OPT_HELP},
 	{ "version",	0, 0, OPT_VERSION},
-	{ "wb",		0, 0, OPT_WB},
-	{ "uwb",	0, 0, OPT_UWB},
 	{ "clock-rate",	1, 0, OPT_CLOCK_RATE},
 	{ "null-audio", 0, 0, OPT_NULL_AUDIO},
@@ -322,5 +319,7 @@
 	    c = pj_strtoul(pj_cstr(&tmp, pj_optarg));
 	    if (c < 0 || c > 6) {
-		printf("Error: expecting integer value 0-6 for --log-level\n");
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: expecting integer value 0-6 "
+			  "for --log-level"));
 		return PJ_EINVAL;
 	    }
@@ -331,5 +330,7 @@
 	    pjsua.app_log_level = pj_strtoul(pj_cstr(&tmp, pj_optarg));
 	    if (pjsua.app_log_level < 0 || pjsua.app_log_level > 6) {
-		printf("Error: expecting integer value 0-6 for --app-log-level\n");
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: expecting integer value 0-6 "
+			  "for --app-log-level"));
 		return PJ_EINVAL;
 	    }
@@ -352,16 +353,9 @@
 	    break;
 
-	case OPT_WB:
-	    pjsua.has_wb = 1;
-	    break;
-
-	case OPT_UWB:
-	    pjsua.has_uwb = 1;
-	    break;
-
 	case OPT_CLOCK_RATE:
 	    lval = pj_strtoul(pj_cstr(&tmp, pj_optarg));
 	    if (lval < 8000 || lval > 48000) {
-		printf("Error: expecting value between 8000-48000 for clock rate\n");
+		PJ_LOG(1,(THIS_FILE, "Error: expecting value between "
+				     "8000-48000 for clock rate"));
 		return PJ_EINVAL;
 	    }
@@ -372,5 +366,7 @@
 	    lval = pj_strtoul(pj_cstr(&tmp, pj_optarg));
 	    if (lval < 1 || lval > 65535) {
-		printf("Error: expecting integer value for --local-port\n");
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: expecting integer value for "
+			  "--local-port"));
 		return PJ_EINVAL;
 	    }
@@ -380,5 +376,7 @@
 	case OPT_PROXY:   /* proxy */
 	    if (pjsua_verify_sip_url(pj_optarg) != 0) {
-		printf("Error: invalid SIP URL '%s' in proxy argument\n", pj_optarg);
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: invalid SIP URL '%s' "
+			  "in proxy argument", pj_optarg));
 		return PJ_EINVAL;
 	    }
@@ -388,5 +386,7 @@
 	case OPT_OUTBOUND_PROXY:   /* outbound proxy */
 	    if (pjsua_verify_sip_url(pj_optarg) != 0) {
-		printf("Error: invalid SIP URL '%s' in outbound proxy argument\n", pj_optarg);
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: invalid SIP URL '%s' "
+			  "in outbound proxy argument", pj_optarg));
 		return PJ_EINVAL;
 	    }
@@ -396,5 +396,7 @@
 	case OPT_REGISTRAR:   /* registrar */
 	    if (pjsua_verify_sip_url(pj_optarg) != 0) {
-		printf("Error: invalid SIP URL '%s' in registrar argument\n", pj_optarg);
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: invalid SIP URL '%s' in "
+			  "registrar argument", pj_optarg));
 		return PJ_EINVAL;
 	    }
@@ -405,5 +407,7 @@
 	    cur_acc->reg_timeout = pj_strtoul(pj_cstr(&tmp,pj_optarg));
 	    if (cur_acc->reg_timeout < 1 || cur_acc->reg_timeout > 3600) {
-		printf("Error: invalid value for --reg-timeout (expecting 1-3600)\n");
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: invalid value for --reg-timeout "
+			  "(expecting 1-3600)"));
 		return PJ_EINVAL;
 	    }
@@ -412,5 +416,7 @@
 	case OPT_ID:   /* id */
 	    if (pjsua_verify_sip_url(pj_optarg) != 0) {
-		printf("Error: invalid SIP URL '%s' in local id argument\n", pj_optarg);
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: invalid SIP URL '%s' "
+			  "in local id argument", pj_optarg));
 		return PJ_EINVAL;
 	    }
@@ -421,5 +427,7 @@
 	case OPT_CONTACT:   /* contact */
 	    if (pjsua_verify_sip_url(pj_optarg) != 0) {
-		printf("Error: invalid SIP URL '%s' in contact argument\n", pj_optarg);
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: invalid SIP URL '%s' "
+			  "in contact argument", pj_optarg));
 		return PJ_EINVAL;
 	    }
@@ -460,5 +468,7 @@
 		pjsua.stun_port1 = pj_strtoul(pj_cstr(&tmp, p+1));
 		if (pjsua.stun_port1 < 1 || pjsua.stun_port1 > 65535) {
-		    printf("Error: expecting port number with option --use-stun1\n");
+		    PJ_LOG(1,(THIS_FILE, 
+			      "Error: expecting port number with "
+			      "option --use-stun1"));
 		    return PJ_EINVAL;
 		}
@@ -476,5 +486,7 @@
 		pjsua.stun_port2 = pj_strtoul(pj_cstr(&tmp,p+1));
 		if (pjsua.stun_port2 < 1 || pjsua.stun_port2 > 65535) {
-		    printf("Error: expecting port number with option --use-stun2\n");
+		    PJ_LOG(1,(THIS_FILE, 
+			      "Error: expecting port number with "
+			      "option --use-stun2"));
 		    return PJ_EINVAL;
 		}
@@ -487,9 +499,12 @@
 	case OPT_ADD_BUDDY: /* Add to buddy list. */
 	    if (pjsua_verify_sip_url(pj_optarg) != 0) {
-		printf("Error: invalid URL '%s' in --add-buddy option\n", pj_optarg);
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: invalid URL '%s' in "
+			  "--add-buddy option", pj_optarg));
 		return -1;
 	    }
 	    if (pjsua.buddy_cnt == PJSUA_MAX_BUDDIES) {
-		printf("Error: too many buddies in buddy list.\n");
+		PJ_LOG(1,(THIS_FILE, 
+			  "Error: too many buddies in buddy list."));
 		return -1;
 	    }
@@ -517,5 +532,6 @@
 	    if (pjsua.start_rtp_port < 1 || pjsua.start_rtp_port > 65535) {
 		PJ_LOG(1,(THIS_FILE,
-			  "Error: rtp-port argument value (expecting 1-65535"));
+			  "Error: rtp-port argument value "
+			  "(expecting 1-65535"));
 		return -1;
 	    }
@@ -548,5 +564,6 @@
 	    if (pjsua.auto_answer < 100 || pjsua.auto_answer > 699) {
 		PJ_LOG(1,(THIS_FILE,
-			  "Error: invalid code in --auto-answer (expecting 100-699"));
+			  "Error: invalid code in --auto-answer "
+			  "(expecting 100-699"));
 		return -1;
 	    }
@@ -564,5 +581,6 @@
 	    pjsua.uas_refresh = my_atoi(pj_optarg);
 	    if (pjsua.uas_refresh < 1) {
-		PJ_LOG(1,(THIS_FILE,"Invalid value for --uas-refresh (must be >0)"));
+		PJ_LOG(1,(THIS_FILE,
+			  "Invalid value for --uas-refresh (must be >0)"));
 		return -1;
 	    }
@@ -572,5 +590,7 @@
 	    pjsua.uas_duration = my_atoi(pj_optarg);
 	    if (pjsua.uas_duration < 1) {
-		PJ_LOG(1,(THIS_FILE,"Invalid value for --uas-duration (must be >0)"));
+		PJ_LOG(1,(THIS_FILE,
+			  "Invalid value for --uas-duration "
+			  "(must be >0)"));
 		return -1;
 	    }
@@ -580,13 +600,27 @@
 
     if (pj_optind != argc) {
-	printf("Error: unknown options %s\n", argv[pj_optind]);
+	int i;
+
+	if (pjsua_verify_sip_url(argv[pj_optind]) != PJ_SUCCESS) {
+	    PJ_LOG(1,(THIS_FILE, "Invalid SIP URI %s", argv[pj_optind]));
+	    return -1;
+	}
+	pjsua.uri_to_call = pj_str(argv[pj_optind]);
+	pj_optind++;
+
+	/* Add URI to call to buddy list if it's not already there */
+	for (i=0; i<pjsua.buddy_cnt; ++i) {
+	    if (pj_stricmp(&pjsua.buddies[i].uri, &pjsua.uri_to_call)==0)
+		break;
+	}
+	if (i == pjsua.buddy_cnt && pjsua.buddy_cnt < PJSUA_MAX_BUDDIES) {
+	    pjsua.buddies[pjsua.buddy_cnt++].uri = pjsua.uri_to_call;
+	}
+    }
+
+    if (pj_optind != argc) {
+	PJ_LOG(1,(THIS_FILE, "Error: unknown options %s", argv[pj_optind]));
 	return PJ_EINVAL;
     }
-
-    /* Adjust clock rate */
-    if (pjsua.clock_rate == 8000 && pjsua.has_uwb)
-	pjsua.clock_rate = 32000;
-    else if (pjsua.clock_rate == 8000 && pjsua.has_wb)
-	pjsua.clock_rate = 16000;
 
     return PJ_SUCCESS;
@@ -1048,13 +1082,9 @@
     }
     /* Media clock rate. */
-    if (pjsua.has_uwb)
-	pj_strcat2(&cfg, "--uwb\n");
-
-    if (pjsua.has_wb)
-	pj_strcat2(&cfg, "--wb\n");
-
-    pj_ansi_sprintf(line, "--clock-rate %d\n",
-		    pjsua.clock_rate);
-    pj_strcat2(&cfg, line);
+    if (pjsua.clock_rate) {
+	pj_ansi_sprintf(line, "--clock-rate %d\n",
+			pjsua.clock_rate);
+	pj_strcat2(&cfg, line);
+    }
 
 
