Index: linphone/console/commands.c
===================================================================
--- linphone/console/commands.c	(revision 245)
+++ linphone/console/commands.c	(revision 248)
@@ -1209,4 +1209,5 @@
 	if (elem) linphone_proxy_config_done(cfg);
 	else linphone_core_add_proxy_config(lc,cfg);
+	linphone_core_set_default_proxy(lc,cfg);
 	return 1;
 }
@@ -1215,5 +1216,5 @@
 	LinphoneProxyConfig *cfg=NULL;
 	linphone_core_get_default_proxy(lc,&cfg);
-	if (cfg) {
+	if (cfg && linphone_proxy_config_is_registered(cfg)) {
 		linphone_proxy_config_edit(cfg);
 		linphone_proxy_config_enable_register(cfg,FALSE);
@@ -1243,33 +1244,34 @@
 		if (cfg){
 			if (linphone_proxy_config_is_registered(cfg)){
-				linphonec_out("identity=%s duration=%s",
+				linphonec_out("identity=%s duration=%i\n",
 					linphone_proxy_config_get_identity(cfg),
 					linphone_proxy_config_get_expires(cfg));
 			}else if (linphone_proxy_config_register_enabled(cfg)){
-				linphonec_out("registered=-1");
-			}else linphonec_out("registered=0");
-		}else linphonec_out("registered=0");
+				linphonec_out("registered=-1\n");
+			}else linphonec_out("registered=0\n");
+		}else linphonec_out("registered=0\n");
 	}else if (strstr(args,"autoanswer")){
 		if (cfg && linphone_proxy_config_is_registered(cfg))
-			linphonec_out("autoanswer=%i",linphonec_get_autoanswer());
-		else linphonec_out("unregistered");
+			linphonec_out("autoanswer=%i\n",linphonec_get_autoanswer());
+		else linphonec_out("unregistered\n");
 	}else if (strstr(args,"hook")){
 		gstate_t call_state=linphone_core_get_state(lc,GSTATE_GROUP_CALL);
 		if (!cfg || !linphone_proxy_config_is_registered(cfg)){
-			linphonec_out("unregistered");
+			linphonec_out("unregistered\n");
+			return 1;
 		}
 		switch(call_state){
 			case GSTATE_CALL_OUT_INVITE:
-				linphonec_out("hook=dialing");
+				linphonec_out("hook=dialing\n");
 			break;
 			case GSTATE_CALL_IDLE:
-				linphonec_out("hook=offhook");
+				linphonec_out("hook=offhook\n");
 			break;
 			case GSTATE_CALL_OUT_CONNECTED:
-				linphonec_out("hook=%s duration=%i", linphonec_get_callee(),
+				linphonec_out("hook=%s duration=%i\n", linphonec_get_callee(),
 					linphone_core_get_current_call_duration(lc));
 			break;
 			case GSTATE_CALL_IN_CONNECTED:
-				linphonec_out("hook=answered duration=%i" ,
+				linphonec_out("hook=answered duration=%i\n" ,
 					linphone_core_get_current_call_duration(lc));
 			default:
Index: linphone/console/shell.c
===================================================================
--- linphone/console/shell.c	(revision 244)
+++ linphone/console/shell.c	(revision 248)
@@ -76,9 +76,14 @@
 	fprintf(stderr,"Usage:\nlinphonecsh <action> [arguments]\n"
 			"where action is one of\n"
-			"\tinit     : spawn a linphonec daemon (first step to make other actions)\n"
-			"\t\tfollowed by the arguments sent to linphonec\n"
-			"\tgeneric  : sends a generic command to the running linphonec daemon\n"
-			"\t\tfollowed by the generic command surrounded by quotes, for example \"call sip:joe@example.net\"\n"
-			"\tregister : register with specified proxy\n");
+			"\tinit\t\t: spawn a linphonec daemon (first step to make other actions)\n"
+			"\t\t\tfollowed by the arguments sent to linphonec\n"
+			"\tgeneric\t\t: sends a generic command to the running linphonec daemon\n"
+			"\t\t\tfollowed by the generic command surrounded by quotes,\n\t\t\t for example \"call sip:joe@example.net\"\n"
+			"\tregister\t: register; arguments are \n\t\t\t--host <host>\n\t\t\t--username <username>\n\t\t\t--password <password>\n"
+			"\tunregister\t: unregister\n"
+			"\tdial\t\t: dial <sip uri or number>\n"
+			"\tstatus\t\t: can be 'status register', 'status autoanswer' or 'status hook'\n"
+			"\texit\t\t: make the linphonec daemon to exit.\n"
+	);
 	exit(-1);
 }
@@ -94,4 +99,6 @@
 	args[j++]="--tcp";
 	args[j++]=DEFAULT_TCP_PORT;
+	args[j++]="-c";
+	args[j++]="/dev/null";
 	for(i=0;i<argc;++i){
 		args[j++]=argv[i];
@@ -190,5 +197,5 @@
 	char cmd[512];
 	if (argc==1){
-		snprintf(cmd,sizeof(cmd),"call %s",argv[0]);
+		snprintf(cmd,sizeof(cmd),"status %s",argv[0]);
 		return send_generic_command(cmd,TRUE);
 	}else{
@@ -228,5 +235,7 @@
 		}else if (strcmp(argv[argi],"status")==0){
 			return status_execute(argc-argi-1,&argv[argi+1]);
-		}
+		}else if (strcmp(argv[argi],"exit")==0){
+			return send_generic_command("quit",TRUE);
+		}else print_usage();
 	}
   	return 0;
Index: linphone/coreapi/exevents.c
===================================================================
--- linphone/coreapi/exevents.c	(revision 232)
+++ linphone/coreapi/exevents.c	(revision 248)
@@ -931,9 +931,10 @@
 	ms_return_if_fail(cfg!=NULL);
 	cfg->auth_pending=FALSE;
-	cfg->registered=TRUE;
 	gstate_new_state(lc, GSTATE_REG_OK, NULL);
 	osip_message_get_expires(ev->request,0,&h);
-	if (h!=NULL && atoi(h->hvalue)!=0)
+	if (h!=NULL && atoi(h->hvalue)!=0){
+		cfg->registered=TRUE;
 		linphone_proxy_config_register_again_with_updated_contact(cfg,ev->request,ev->response);
+	}else cfg->registered=FALSE;
 }
 
