Index: /pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c
===================================================================
--- /pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c	(revision 923)
+++ /pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c	(revision 924)
@@ -22,4 +22,6 @@
 
 #define THIS_FILE    "main.c"
+#define POOL_SIZE    4000
+#define SND_DEV_NUM  64
 
 /* LIB BASE */
@@ -195,9 +197,9 @@
         pjsip_event_Object * obj;
 		
-	    obj =
+	obj =
 	        (pjsip_event_Object *)PyType_GenericNew(&pjsip_event_Type, 
 						    NULL, NULL);
 		
-	    obj->event = e;
+	obj->event = e;
 		
         PyObject_CallFunctionObjArgs(
@@ -1303,10 +1305,12 @@
         pj_list_init(hdr);
 
-        for (i = 0; i < PyList_Size(py_hdr_list); i++) { 
+        for (i = 0; i < PyList_Size(py_hdr_list); i++) 
+	{ 
             pj_str_t hname, hvalue;
 	    pjsip_generic_string_hdr * new_hdr;
             PyObject * tuple = PyList_GetItem(py_hdr_list, i);
 
-            if (PyTuple_Check(tuple)) {
+            if (PyTuple_Check(tuple)) 
+	    {
                 hname.ptr = PyString_AsString(PyTuple_GetItem(tuple,0));
                 hname.slen = strlen(PyString_AsString
@@ -1341,21 +1345,24 @@
     len = pj_list_size(hdr);
     
-    if (len > 0) {
-	p_hdr = hdr;
+    if (len > 0) 
+    {
+        p_hdr = hdr;
         Py_XDECREF(py_hdr_list);
         py_hdr_list = PyList_New(len);
 
-	for (i = 0; i < len && p_hdr != NULL; i++) {
-	    PyObject * tuple;
-	    PyObject * str;
-
-	    tuple = PyTuple_New(2);
+        for (i = 0; i < len && p_hdr != NULL; i++) 
+	{
+            PyObject * tuple;
+            PyObject * str;
+
+            tuple = PyTuple_New(2);
 	    
-	    str = PyString_FromStringAndSize(p_hdr->name.ptr, p_hdr->name.slen);
-	    PyTuple_SetItem(tuple, 0, str);
-	    str = PyString_FromStringAndSize(hdr->hvalue.ptr, p_hdr->hvalue.slen);
-	    PyTuple_SetItem(tuple, 1, str);
-	    PyList_SetItem(py_hdr_list, i, tuple);
-	    p_hdr = p_hdr->next;
+            str = PyString_FromStringAndSize(p_hdr->name.ptr, p_hdr->name.slen);
+            PyTuple_SetItem(tuple, 0, str);
+            str = PyString_FromStringAndSize
+		(hdr->hvalue.ptr, p_hdr->hvalue.slen);
+            PyTuple_SetItem(tuple, 1, str);
+            PyList_SetItem(py_hdr_list, i, tuple);
+            p_hdr = p_hdr->next;
 	}
     }
@@ -1555,6 +1562,6 @@
     Py_XDECREF(self->realm);
     Py_XDECREF(self->scheme);
-	Py_XDECREF(self->username);
-	Py_XDECREF(self->data);
+    Py_XDECREF(self->username);
+    Py_XDECREF(self->data);
     self->ob_type->tp_free((PyObject*)self);
 }
@@ -1709,6 +1716,8 @@
     size = PyList_Size(py_desc);
     td = (int *)malloc(size * sizeof(int));
-    for (i = 0; i < size; i++) {
-	if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i])) {
+    for (i = 0; i < size; i++) 
+    {
+	if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i])) 
+	{
 	    return NULL;
 	}
@@ -1741,5 +1750,5 @@
     
     pjsua_logging_config_default(&cfg);
-	obj = (logging_config_Object *) logging_config_new
+    obj = (logging_config_Object *) logging_config_new
 		(&logging_config_Type,NULL,NULL);
     obj->msg_logging = cfg.msg_logging;
@@ -1766,5 +1775,5 @@
     }
     pjsua_config_default(&cfg);
-	obj = (config_Object *) config_new(&config_Type, NULL, NULL);
+    obj = (config_Object *) config_new(&config_Type, NULL, NULL);
     obj->max_calls = cfg.max_calls;
     obj->thread_cnt = cfg.thread_cnt;
@@ -1840,5 +1849,5 @@
 static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, PyObject *pArgs)
 {
-	PyObject * logObj;
+    PyObject * logObj;
     logging_config_Object *log;
     pjsua_logging_config cfg;
@@ -1849,5 +1858,6 @@
         return NULL;
     }
-    if (logObj != Py_None) {
+    if (logObj != Py_None) 
+    {
         log = (logging_config_Object *)logObj;
         cfg.msg_logging = log->msg_logging;
@@ -1864,5 +1874,5 @@
     } else {
         status = pjsua_reconfigure_logging(NULL);
-	}
+    }
     return Py_BuildValue("i",status);
 }
@@ -1989,5 +1999,6 @@
     status = pjsua_create();
     
-    if (status == PJ_SUCCESS) {
+    if (status == PJ_SUCCESS) 
+    {
 	status = pj_thread_local_alloc(&thread_id);
 	if (status == PJ_SUCCESS)
@@ -2029,5 +2040,6 @@
     pjsua_media_config_default(&cfg_media);
 
-    if (ua_cfgObj != Py_None) {
+    if (ua_cfgObj != Py_None) 
+    {
 	ua_cfg = (config_Object *)ua_cfgObj;
         cfg_ua.cred_count = ua_cfg->cred_count;
@@ -2068,5 +2080,6 @@
     }
 
-    if (log_cfgObj != Py_None) {
+    if (log_cfgObj != Py_None) 
+    {
         log_cfg = (logging_config_Object *)log_cfgObj;
         cfg_log.msg_logging = log_cfg->msg_logging;
@@ -2085,5 +2098,6 @@
     }
 
-    if (media_cfgObj != Py_None) {
+    if (media_cfgObj != Py_None) 
+    {
         media_cfg = (media_config_Object *)media_cfgObj;
         cfg_media.clock_rate = media_cfg->clock_rate;
@@ -2184,7 +2198,7 @@
     "void py_pjsua.perror (string sender, string title, int status) "
     "Display error message for the specified error code. Parameters: "
-        "sender: The log sender field;  "
-        "title: Message title for the error; "
-        "status: Status code.";
+    "sender: The log sender field;  "
+    "title: Message title for the error; "
+    "status: Status code.";
 
 static char pjsua_create_doc[] =
@@ -2202,7 +2216,7 @@
     "optional, and the default values will be used when the config is not "
     "specified. Parameters: "
-        "ua_cfg : User agent configuration;  "
-        "log_cfg : Optional logging configuration; "
-        "media_cfg : Optional media configuration.";
+    "ua_cfg : User agent configuration;  "
+    "log_cfg : Optional logging configuration; "
+    "media_cfg : Optional media configuration.";
 
 static char pjsua_start_doc[] =
@@ -2222,5 +2236,5 @@
     "Poll pjsua for events, and if necessary block the caller thread for the "
     "specified maximum interval (in miliseconds) Parameters: "
-        "msec_timeout: Maximum time to wait, in miliseconds. "
+    "msec_timeout: Maximum time to wait, in miliseconds. "
     "Returns: The number of events that have been handled during the poll. "
     "Negative value indicates error, and application can retrieve the error "
@@ -2230,5 +2244,5 @@
     "int py_pjsua.verify_sip_url (string c_url) "
     "Verify that valid SIP url is given Parameters: "
-        "c_url: The URL, as NULL terminated string.";
+    "c_url: The URL, as NULL terminated string.";
 
 static char pjsua_pool_create_doc[] =
@@ -2236,7 +2250,7 @@
                                             "int increment) "
     "Create memory pool Parameters: "
-        "name: Optional pool name; "
-        "init_size: Initial size of the pool;  "
-        "increment: Increment size.";
+    "name: Optional pool name; "
+    "init_size: Initial size of the pool;  "
+    "increment: Increment size.";
 
 static char pjsua_get_pjsip_endpt_doc[] =
@@ -2260,5 +2274,5 @@
     "Application can call this function at any time (after pjsua_create(), of "
     "course) to change logging settings. Parameters: "
-        "c: Logging configuration.";
+    "c: Logging configuration.";
 
 static char pjsua_logging_config_default_doc[] =
@@ -2460,5 +2474,5 @@
     if (self != NULL)
     {
-		self->public_addr = PyString_FromString("");
+        self->public_addr = PyString_FromString("");
         if (self->public_addr == NULL)
     	{
@@ -2719,5 +2733,5 @@
     /* Type-specific fields go here. */
     PyObject * host;
-	int port;
+    int port;
 } host_port_Object;
 
@@ -3060,5 +3074,5 @@
 	
     pjsua_stun_config_default(&cfg);
-	obj = (stun_config_Object *)stun_config_new(&stun_config_Type, NULL, NULL);
+    obj = (stun_config_Object *)stun_config_new(&stun_config_Type, NULL, NULL);
     obj->stun_port1 = cfg.stun_port1;
     obj->stun_port2 = cfg.stun_port2;
@@ -3087,5 +3101,5 @@
     }
     pjsua_transport_config_default(&cfg);
-	obj = (transport_config_Object *)transport_config_new
+    obj = (transport_config_Object *)transport_config_new
 		(&transport_config_Type,NULL,NULL);
     obj->public_addr = 
@@ -3117,5 +3131,5 @@
 (PyObject *pSelf, PyObject *pArgs)
 {
-	PyObject * tmpObj;
+    PyObject * tmpObj;
     stun_config_Object *obj;
     pjsua_stun_config *cfg;
@@ -3125,7 +3139,7 @@
         return NULL;
     }
-	if (tmpObj != Py_None)
-	{
-		obj = (stun_config_Object *) tmpObj;
+    if (tmpObj != Py_None)
+    {
+        obj = (stun_config_Object *) tmpObj;
         cfg = (pjsua_stun_config *)malloc(sizeof(pjsua_stun_config));
         cfg->stun_port1 = obj->stun_port1;
@@ -3135,7 +3149,7 @@
         cfg->stun_srv2.ptr = PyString_AsString(obj->stun_srv2);
         cfg->stun_srv2.slen = strlen(PyString_AsString(obj->stun_srv2));
-	} else {
-		cfg = NULL;
-	}
+    } else {
+        cfg = NULL;
+    }
     pjsua_normalize_stun_config(cfg);
     obj->stun_port1 = cfg->stun_port1;
@@ -3161,5 +3175,5 @@
     int type;
     
-	PyObject * tmpObj;
+    PyObject * tmpObj;
     transport_config_Object *obj;
     pjsua_transport_config cfg;
@@ -3169,6 +3183,6 @@
         return NULL;
     }
-	if (tmpObj != Py_None)
-	{
+    if (tmpObj != Py_None)
+    {
         obj = (transport_config_Object *)tmpObj;
         cfg.public_addr.ptr = PyString_AsString(obj->public_addr);
@@ -3189,7 +3203,7 @@
             strlen(PyString_AsString(obj->stun_config->stun_srv2));
         status = pjsua_transport_create(type, &cfg, &id);
-	} else {
+    } else {
         status = pjsua_transport_create(type, NULL, &id);
-	}
+    }
     
     
@@ -3204,5 +3218,5 @@
 {
     pj_status_t status;	    
-	PyObject * tmpObj;
+    PyObject * tmpObj;
     pjsip_transport_Object *obj;	
     pjsua_transport_id id;
@@ -3212,5 +3226,5 @@
     }
     if (tmpObj != Py_None)
-	{
+    {
         obj = (pjsip_transport_Object *)tmpObj;
         status = pjsua_transport_register(obj->tp, &id);
@@ -3683,5 +3697,5 @@
         if (s[0]) 
         {
-        self->buf_[idx] = s[0];
+            self->buf_[idx] = s[0];
         }	 
 	else 
@@ -3829,5 +3843,5 @@
     obj = (acc_config_Object *)acc_config_new(&acc_config_Type, NULL, NULL);
     obj->cred_count = cfg.cred_count;
-    for (i = 0; i < 8; i++) 
+    for (i = 0; i < PJSUA_MAX_ACC; i++) 
     {
         /*obj->cred_info[i] = cfg.cred_info[i];*/
@@ -3863,5 +3877,5 @@
         PyString_FromStringAndSize(cfg.reg_uri.ptr, cfg.reg_uri.slen);
     obj->proxy_cnt = cfg.proxy_cnt;
-    for (i = 0; i < 8; i++) 
+    for (i = 0; i < PJSUA_MAX_ACC; i++) 
     {
 	PyObject * str;
@@ -3956,5 +3970,5 @@
 {    
     int is_default;
-	PyObject * acObj;
+    PyObject * acObj;
     acc_config_Object * ac;
     pjsua_acc_config cfg;
@@ -3971,115 +3985,9 @@
     pjsua_acc_config_default(&cfg);
     if (acObj != Py_None)
-	{
+    {
         ac = (acc_config_Object *)acObj;
         cfg.cred_count = ac->cred_count;
-        for (i = 0; i < 8; i++) 
+        for (i = 0; i < PJSUA_MAX_ACC; i++) 
 	{
-            /*cfg.cred_info[i] = ac->cred_info[i];*/
-	        pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *)
-				PyList_GetItem((PyObject *)ac->cred_info,i);
-	        cfg.cred_info[i].data.ptr = PyString_AsString(ci->data);
-	        cfg.cred_info[i].data.slen = strlen(PyString_AsString(ci->data));
-	        cfg.cred_info[i].realm.ptr = PyString_AsString(ci->realm);
-	        cfg.cred_info[i].realm.slen = strlen(PyString_AsString(ci->realm));
-	        cfg.cred_info[i].scheme.ptr = PyString_AsString(ci->scheme);
-	        cfg.cred_info[i].scheme.slen = strlen
-				(PyString_AsString(ci->scheme));
-	        cfg.cred_info[i].username.ptr = PyString_AsString(ci->username);
-	        cfg.cred_info[i].username.slen = strlen
-				(PyString_AsString(ci->username));
-	        cfg.cred_info[i].data_type = ci->data_type;
-	}
-        cfg.force_contact.ptr = PyString_AsString(ac->force_contact);
-        cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact));
-        cfg.id.ptr = PyString_AsString(ac->id);
-        cfg.id.slen = strlen(PyString_AsString(ac->id));
-        cfg.priority = ac->priority;
-        for (i = 0; i < 8; i++) {
-            /*cfg.proxy[i] = ac->proxy[i];*/
-	        cfg.proxy[i].ptr = PyString_AsString
-				(PyList_GetItem((PyObject *)ac->proxy,i));
-	}
-        cfg.proxy_cnt = ac->proxy_cnt;
-        cfg.publish_enabled = ac->publish_enabled;
-        cfg.reg_timeout = ac->reg_timeout;
-        cfg.reg_uri.ptr = PyString_AsString(ac->reg_uri);
-        cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri));
-    
-        status = pjsua_acc_add(&cfg, is_default, &p_acc_id);
-    } else {
-        status = pjsua_acc_add(NULL, is_default, &p_acc_id);
-	}
-    
-    return Py_BuildValue("ii", status, p_acc_id);
-}
-
-/*
- * py_pjsua_acc_add_local
- * !modified @ 051206
- */
-static PyObject *py_pjsua_acc_add_local
-(PyObject *pSelf, PyObject *pArgs)
-{    
-    int is_default;
-    int tid;
-    
-    int p_acc_id;
-    int status;
-	
-
-    if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default))
-    {
-        return NULL;
-    }
-	
-    
-    status = pjsua_acc_add_local(tid, is_default, &p_acc_id);
-    
-    return Py_BuildValue("ii", status, p_acc_id);
-}
-
-/*
- * py_pjsua_acc_del
- */
-static PyObject *py_pjsua_acc_del
-(PyObject *pSelf, PyObject *pArgs)
-{    
-    int acc_id;
-    int status;
-
-    if (!PyArg_ParseTuple(pArgs, "i", &acc_id))
-    {
-        return NULL;
-    }
-	
-	
-    status = pjsua_acc_del(acc_id);	
-    return Py_BuildValue("i", status);
-}
-
-/*
- * py_pjsua_acc_modify
- */
-static PyObject *py_pjsua_acc_modify
-(PyObject *pSelf, PyObject *pArgs)
-{    	
-	PyObject * acObj;
-    acc_config_Object * ac;
-    pjsua_acc_config cfg;	
-    int acc_id;
-    int status;
-    int i;
-
-    if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &acObj))
-    {
-        return NULL;
-    }
-    if (acObj != Py_None)
-	{
-		ac = (acc_config_Object *)acObj;
-        cfg.cred_count = ac->cred_count;
-        for (i = 0; i < 8; i++) 
-		{
             /*cfg.cred_info[i] = ac->cred_info[i];*/
             pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *)
@@ -4095,5 +4003,6 @@
             cfg.cred_info[i].username.slen = strlen
 				(PyString_AsString(ci->username));
-		}
+            cfg.cred_info[i].data_type = ci->data_type;
+	}
         cfg.force_contact.ptr = PyString_AsString(ac->force_contact);
         cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact));
@@ -4101,9 +4010,116 @@
         cfg.id.slen = strlen(PyString_AsString(ac->id));
         cfg.priority = ac->priority;
-        for (i = 0; i < 8; i++) {
+        for (i = 0; i < PJSUA_MAX_ACC; i++) 
+	{
             /*cfg.proxy[i] = ac->proxy[i];*/
-	        cfg.proxy[i].ptr = PyString_AsString
+            cfg.proxy[i].ptr = PyString_AsString
 				(PyList_GetItem((PyObject *)ac->proxy,i));
-		}
+	}
+        cfg.proxy_cnt = ac->proxy_cnt;
+        cfg.publish_enabled = ac->publish_enabled;
+        cfg.reg_timeout = ac->reg_timeout;
+        cfg.reg_uri.ptr = PyString_AsString(ac->reg_uri);
+        cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri));
+    
+        status = pjsua_acc_add(&cfg, is_default, &p_acc_id);
+    } else {
+        status = pjsua_acc_add(NULL, is_default, &p_acc_id);
+    }
+    
+    return Py_BuildValue("ii", status, p_acc_id);
+}
+
+/*
+ * py_pjsua_acc_add_local
+ * !modified @ 051206
+ */
+static PyObject *py_pjsua_acc_add_local
+(PyObject *pSelf, PyObject *pArgs)
+{    
+    int is_default;
+    int tid;
+    
+    int p_acc_id;
+    int status;
+	
+
+    if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default))
+    {
+        return NULL;
+    }
+	
+    
+    status = pjsua_acc_add_local(tid, is_default, &p_acc_id);
+    
+    return Py_BuildValue("ii", status, p_acc_id);
+}
+
+/*
+ * py_pjsua_acc_del
+ */
+static PyObject *py_pjsua_acc_del
+(PyObject *pSelf, PyObject *pArgs)
+{    
+    int acc_id;
+    int status;
+
+    if (!PyArg_ParseTuple(pArgs, "i", &acc_id))
+    {
+        return NULL;
+    }
+	
+	
+    status = pjsua_acc_del(acc_id);	
+    return Py_BuildValue("i", status);
+}
+
+/*
+ * py_pjsua_acc_modify
+ */
+static PyObject *py_pjsua_acc_modify
+(PyObject *pSelf, PyObject *pArgs)
+{    	
+    PyObject * acObj;
+    acc_config_Object * ac;
+    pjsua_acc_config cfg;	
+    int acc_id;
+    int status;
+    int i;
+
+    if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &acObj))
+    {
+        return NULL;
+    }
+    if (acObj != Py_None)
+    {
+        ac = (acc_config_Object *)acObj;
+        cfg.cred_count = ac->cred_count;
+        for (i = 0; i < PJSUA_MAX_ACC; i++) 
+	{
+            /*cfg.cred_info[i] = ac->cred_info[i];*/
+            pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *)
+				PyList_GetItem((PyObject *)ac->cred_info,i);
+            cfg.cred_info[i].data.ptr = PyString_AsString(ci->data);
+            cfg.cred_info[i].data.slen = strlen(PyString_AsString(ci->data));
+            cfg.cred_info[i].realm.ptr = PyString_AsString(ci->realm);
+            cfg.cred_info[i].realm.slen = strlen(PyString_AsString(ci->realm));
+            cfg.cred_info[i].scheme.ptr = PyString_AsString(ci->scheme);
+            cfg.cred_info[i].scheme.slen = strlen
+				(PyString_AsString(ci->scheme));
+            cfg.cred_info[i].username.ptr = PyString_AsString(ci->username);
+            cfg.cred_info[i].username.slen = strlen
+				(PyString_AsString(ci->username));
+	}
+        cfg.force_contact.ptr = PyString_AsString(ac->force_contact);
+        cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact));
+        cfg.id.ptr = PyString_AsString(ac->id);
+        cfg.id.slen = strlen(PyString_AsString(ac->id));
+        cfg.priority = ac->priority;
+        for (i = 0; i < PJSUA_MAX_ACC; i++) 
+	{
+            /*cfg.proxy[i] = ac->proxy[i];*/
+             cfg.proxy[i].ptr = PyString_AsString
+				(PyList_GetItem((PyObject *)ac->proxy,i));
+	}
         cfg.proxy_cnt = ac->proxy_cnt;
         cfg.publish_enabled = ac->publish_enabled;
@@ -4112,7 +4128,7 @@
         cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri));	
         status = pjsua_acc_modify(acc_id, &cfg);
-	} else {
-		status = pjsua_acc_modify(acc_id, NULL);
-	}
+    } else {
+        status = pjsua_acc_modify(acc_id, NULL);
+    }
     return Py_BuildValue("i", status);
 }
@@ -4178,10 +4194,12 @@
     
     status = pjsua_acc_get_info(acc_id, &info);
-    if (status == PJ_SUCCESS) {
+    if (status == PJ_SUCCESS) 
+    {
 	obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL, NULL);
         obj->acc_uri =
             PyString_FromStringAndSize(info.acc_uri.ptr, 
             info.acc_uri.slen);
-        for (i = 0; i < PJ_ERR_MSG_SIZE; i++) {
+        for (i = 0; i < PJ_ERR_MSG_SIZE; i++) 
+	{
             obj->buf_[i] = info.buf_[i];
 	}
@@ -4222,7 +4240,9 @@
     
     list = PyList_New(c);
-    for (i = 0; i < c; i++) {
+    for (i = 0; i < c; i++) 
+    {
         int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
-        if (ret == -1) {
+        if (ret == -1) 
+	{
             return NULL;
         }
@@ -4252,25 +4272,27 @@
     
     list = PyList_New(c);
-    for (i = 0; i < c; i++) {
+    for (i = 0; i < c; i++) 
+    {
         int ret;
-	int j;
-	acc_info_Object *obj;
-	obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL,NULL);
-	obj->acc_uri = PyString_FromStringAndSize
+        int j;
+        acc_info_Object *obj;
+        obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL,NULL);
+        obj->acc_uri = PyString_FromStringAndSize
 	    (info[i].acc_uri.ptr, info[i].acc_uri.slen);
-	for(j = 0; j < PJ_ERR_MSG_SIZE; j++) {
-	    obj->buf_[j] = info[i].buf_[j];
+        for(j = 0; j < PJ_ERR_MSG_SIZE; j++) 
+	{
+            obj->buf_[j] = info[i].buf_[j];
 	}
-	obj->expires = info[i].expires;
-	obj->has_registration = info[i].has_registration;
-	obj->id = info[i].id;
-	obj->is_default = info[i].is_default;
-	obj->online_status = info[i].online_status;
-	obj->status = info[i].status;
-	obj->status_text = PyString_FromStringAndSize(info[i].status_text.ptr,
+        obj->expires = info[i].expires;
+        obj->has_registration = info[i].has_registration;
+        obj->id = info[i].id;
+        obj->is_default = info[i].is_default;
+        obj->online_status = info[i].online_status;
+        obj->status = info[i].status;
+        obj->status_text = PyString_FromStringAndSize(info[i].status_text.ptr,
 	    info[i].status_text.slen);
-	ret = PyList_SetItem(list, i, (PyObject *)obj);
+        ret = PyList_SetItem(list, i, (PyObject *)obj);
         if (ret == -1) {
-	    return NULL;
+            return NULL;
         }
     }
@@ -4309,5 +4331,5 @@
 {    	
     int acc_id;	
-	PyObject * tmpObj;
+    PyObject * tmpObj;
     pjsip_rx_data_Object * obj;
     pjsip_rx_data * rdata;
@@ -4318,11 +4340,11 @@
     }
     if (tmpObj != Py_None)
-	{
+    {
         obj = (pjsip_rx_data_Object *)tmpObj;
         rdata = obj->rdata;
         acc_id = pjsua_acc_find_for_incoming(rdata);
-	} else {
+    } else {
         acc_id = pjsua_acc_find_for_incoming(NULL);
-	}
+    }
     return Py_BuildValue("i", acc_id);
 }
@@ -4337,5 +4359,5 @@
     int status;
     int acc_id;
-	PyObject * pObj;
+    PyObject * pObj;
     pj_pool_Object * p;
     pj_pool_t * pool;
@@ -4350,5 +4372,5 @@
     }
     if (pObj != Py_None)
-	{
+    {
         p = (pj_pool_Object *)pObj;
         pool = p->pool;    
@@ -4356,7 +4378,7 @@
         uri.slen = strlen(PyString_AsString(stru));
         status = pjsua_acc_create_uac_contact(pool, &contact, acc_id, &uri);
-	} else {
+    } else {
         status = pjsua_acc_create_uac_contact(NULL, &contact, acc_id, &uri);
-	}
+    }
     strc = PyString_FromStringAndSize(contact.ptr, contact.slen);
 	
@@ -4373,10 +4395,10 @@
     int status;
     int acc_id;	
-	PyObject * pObj;
+    PyObject * pObj;
     pj_pool_Object * p;
     pj_pool_t * pool;
     PyObject * strc;
     pj_str_t contact;
-	PyObject * rObj;
+    PyObject * rObj;
     pjsip_rx_data_Object * objr;
     pjsip_rx_data * rdata;
@@ -4387,17 +4409,17 @@
     }
     if (pObj != Py_None)
-	{
+    {
         p = (pj_pool_Object *)pObj;
         pool = p->pool;
     } else {
 		pool = NULL;
-	}
+    }
     if (rObj != Py_None)
-	{
-		objr = (pjsip_rx_data_Object *)rObj;
+    {
+        objr = (pjsip_rx_data_Object *)rObj;
         rdata = objr->rdata;
-	} else {
+    } else {
         rdata = NULL;
-	}
+    }
     status = pjsua_acc_create_uas_contact(pool, &contact, acc_id, rdata);
     strc = PyString_FromStringAndSize(contact.ptr, contact.slen);
@@ -4762,4 +4784,29 @@
 
 /*
+ * py_pjsua_buddy_config_default
+ */
+static PyObject *py_pjsua_buddy_config_default
+(PyObject *pSelf, PyObject *pArgs)
+{    
+    buddy_config_Object *obj;	
+    pjsua_buddy_config cfg;
+
+    if (!PyArg_ParseTuple(pArgs, ""))
+    {
+        return NULL;
+    }
+    
+    pjsua_buddy_config_default(&cfg);
+    obj = (buddy_config_Object *) buddy_config_new
+		(&buddy_config_Type,NULL,NULL);
+    obj->uri = PyString_FromStringAndSize(
+        cfg.uri.ptr, cfg.uri.slen
+    );
+    obj->subscribe = cfg.subscribe;
+    
+    return (PyObject *)obj;
+}
+
+/*
  * py_pjsua_get_buddy_count
  */
@@ -4814,7 +4861,9 @@
     status = pjsua_enum_buddies(id, &c);
     list = PyList_New(c);
-    for (i = 0; i < c; i++) {
+    for (i = 0; i < c; i++) 
+    {
         int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
-        if (ret == -1) {
+        if (ret == -1) 
+	{
             return NULL;
 	}
@@ -4844,5 +4893,6 @@
     
     status = pjsua_buddy_get_info(buddy_id, &info);
-    if (status == PJ_SUCCESS) {
+    if (status == PJ_SUCCESS) 
+    {
 	obj = (buddy_info_Object *)buddy_info_new(&buddy_info_Type,NULL,NULL);
         obj->id = info.id;
@@ -4861,5 +4911,6 @@
             info.status_text.slen);
         obj->monitor_pres = info.monitor_pres;
-        for (i = 0; i < 256; i++) {
+        for (i = 0; i < 256; i++) 
+	{
 	    
             obj->buf_[i] = info.buf_[i];
@@ -4893,6 +4944,6 @@
     }
     if (bcObj != Py_None)
-	{
-		bc = (buddy_config_Object *)bcObj;
+    {
+        bc = (buddy_config_Object *)bcObj;
 
         cfg.subscribe = bc->subscribe;
@@ -4901,5 +4952,5 @@
     
         status = pjsua_buddy_add(&cfg, &p_buddy_id);
-	} else {
+    } else {
         status = pjsua_buddy_add(NULL, &p_buddy_id);
     }
@@ -4974,5 +5025,6 @@
     int status;
     int acc_id;
-    pj_str_t to, mime_type, content;
+    pj_str_t * mime_type;
+    pj_str_t to, content;
     PyObject * st;
     PyObject * smt;
@@ -4981,7 +5033,9 @@
     PyObject * omdObj;
     msg_data_Object * omd;
+    
     int user_data;
     pj_pool_t *pool;
 
+   
     if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id, 
 		&st, &smt, &sc, &omdObj, &user_data))
@@ -4989,13 +5043,19 @@
         return NULL;
     }
-	
+    if (smt != NULL)
+    {
+        mime_type = (pj_str_t *)malloc(sizeof(pj_str_t));
+        mime_type->ptr = PyString_AsString(smt);
+        mime_type->slen = strlen(PyString_AsString(smt));
+    } else {
+        mime_type = NULL;
+    }
     to.ptr = PyString_AsString(st);
     to.slen = strlen(PyString_AsString(st));
-    mime_type.ptr = PyString_AsString(smt);
-    mime_type.slen = strlen(PyString_AsString(smt));
+    
     content.ptr = PyString_AsString(sc);
     content.slen = strlen(PyString_AsString(sc));
     if (omdObj != Py_None)
-	{
+    {
 		
         omd = (msg_data_Object *)omdObj;
@@ -5005,16 +5065,19 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
 
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
-        status = pjsua_im_send(acc_id, &to, &mime_type, 
-			&content, &msg_data, &user_data);	
+        status = pjsua_im_send(acc_id, &to, mime_type, 
+			&content, &msg_data, (void *)user_data);	
         pj_pool_release(pool);
-	} else {
+    } else {
 		
-        status = pjsua_im_send(acc_id, &to, NULL, 
+        status = pjsua_im_send(acc_id, &to, mime_type, 
 			&content, NULL, NULL);	
-	}
-	
+    }
+    if (mime_type != NULL)
+    {
+        free(mime_type);
+    }
     return Py_BuildValue("i",status);
 }
@@ -5032,5 +5095,5 @@
     int is_typing;
     pjsua_msg_data msg_data;
-	PyObject * omdObj;
+    PyObject * omdObj;
     msg_data_Object * omd;
     pj_pool_t * pool;
@@ -5044,5 +5107,5 @@
     to.slen = strlen(PyString_AsString(st));    
     if (omdObj != Py_None)
-	{
+    {
         omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -5051,15 +5114,18 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
 
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
         status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data);	
         pj_pool_release(pool);
-	} else {
+    } else {
         status = pjsua_im_typing(acc_id, &to, is_typing, NULL);
-	}
+    }
     return Py_BuildValue("i",status);
 }
 
+static char pjsua_buddy_config_default_doc[] =
+    "py_pjsua.Buddy_Config py_pjsua.buddy_config_default () "
+    "Set default values to the buddy config.";
 static char pjsua_get_buddy_count_doc[] =
     "int py_pjsua.get_buddy_count () "
@@ -5281,5 +5347,5 @@
         }        
 	
-	self->listeners = (PyListObject *)PyList_New(254);
+	self->listeners = (PyListObject *)PyList_New(PJSUA_MAX_CONF_PORTS);
         if (self->listeners == NULL)
     	{
@@ -5473,5 +5539,5 @@
     if (self != NULL)
     {
-        self->name = (PyListObject *)PyList_New(64);
+        self->name = (PyListObject *)PyList_New(SND_DEV_NUM);
         if (self->name == NULL)
     	{
@@ -5968,7 +6034,9 @@
     
     list = PyList_New(c);
-    for (i = 0; i < c; i++) {
+    for (i = 0; i < c; i++) 
+    {
         int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
-        if (ret == -1) {
+        if (ret == -1) 
+	{
             return NULL;
 	}
@@ -6007,5 +6075,5 @@
     obj->slot_id = info.slot_id;
     
-    for (i = 0; i < 254; i++) {
+    for (i = 0; i < PJSUA_MAX_CONF_PORTS; i++) {
 	PyObject * item = Py_BuildValue("i",info.listeners[i]);
 	PyList_SetItem((PyObject *)obj->listeners, i, item);
@@ -6021,10 +6089,10 @@
 {    	
     int p_id;
-	PyObject * oportObj;
+    PyObject * oportObj;
     pjmedia_port_Object * oport;
-	pjmedia_port * port;
-	PyObject * opoolObj;
+    pjmedia_port * port;
+    PyObject * opoolObj;
     pj_pool_Object * opool;
-	pj_pool_t * pool;
+    pj_pool_t * pool;
     
     int status;	
@@ -6036,18 +6104,18 @@
     }
     if (opoolObj != Py_None)
-	{
+    {
         opool = (pj_pool_Object *)opoolObj;
 		pool = opool->pool;
-	} else {
-		opool = NULL;
-		pool = NULL;
+    } else {
+       opool = NULL;
+       pool = NULL;
     }
     if (oportObj != Py_None)
-	{
+    {
         oport = (pjmedia_port_Object *)oportObj;
 		port = oport->port;
-	} else {
+    } else {
         oport = NULL;
-		port = NULL;
+        port = NULL;
     }
 
@@ -6222,5 +6290,5 @@
     pj_str_t str;
     PyObject * enc_param;
-	pj_str_t strparam;
+    pj_str_t strparam;
     int enc_type;
     
@@ -6235,6 +6303,6 @@
     str.ptr = PyString_AsString(filename);
     str.slen = strlen(PyString_AsString(filename));
-	strparam.ptr = PyString_AsString(enc_param);
-	strparam.slen = strlen(PyString_AsString(enc_param));
+    strparam.ptr = PyString_AsString(enc_param);
+    strparam.slen = strlen(PyString_AsString(enc_param));
     status = pjsua_recorder_create
 		(&str, enc_type, NULL, max_size, options, &p_id);
@@ -6293,5 +6361,5 @@
     PyObject *list;
     
-    pjmedia_snd_dev_info info[64];
+    pjmedia_snd_dev_info info[SND_DEV_NUM];
     unsigned c, i;
     if (!PyArg_ParseTuple(pArgs, ""))
@@ -6304,7 +6372,8 @@
     
     list = PyList_New(c);
-    for (i = 0; i < c; i++) {
+    for (i = 0; i < c; i++) 
+    {
         int ret;
-	int j;
+        int j;
         pjmedia_snd_dev_info_Object * obj;
         obj = (pjmedia_snd_dev_info_Object *)pjmedia_snd_dev_info_new
@@ -6313,16 +6382,17 @@
         obj->input_count = info[i].input_count;
         obj->output_count = info[i].output_count;
-        for (j = 0; j < 64; j++)
+        for (j = 0; j < SND_DEV_NUM; j++)
 	{
-	    PyObject * ostr;
-	    char * str;
-	    str = (char *)malloc(sizeof(char));
-	    str[0] = info[i].name[j];
-	    ostr = PyString_FromStringAndSize(str,1);
+            PyObject * ostr;
+            char * str;
+            str = (char *)malloc(sizeof(char));
+            str[0] = info[i].name[j];
+            ostr = PyString_FromStringAndSize(str,1);
             PyList_SetItem((PyObject *)obj->name, j, ostr);
-	    free(str);
+            free(str);
 	}
         ret = PyList_SetItem(list, i, (PyObject *)obj);
-        if (ret == -1) {
+        if (ret == -1) 
+	{
             return NULL;
 	}
@@ -6478,5 +6548,6 @@
     
     list = PyList_New(c);
-    for (i = 0; i < c; i++) {
+    for (i = 0; i < c; i++) 
+    {
         int ret;
         int j;
@@ -6576,5 +6647,5 @@
     pj_str_t str;
     pjmedia_codec_param param;
-	PyObject * tmpObj;
+    PyObject * tmpObj;
     pjmedia_codec_param_Object *obj;
     
@@ -6588,5 +6659,5 @@
     str.slen = strlen(PyString_AsString(id));
     if (tmpObj != Py_None)
-	{
+    {
         obj = (pjmedia_codec_param_Object *)tmpObj;
         param.info.avg_bps = obj->info->avg_bps;
@@ -6607,5 +6678,5 @@
     } else {
         status = pjsua_codec_set_param(&str, NULL);
-	}
+    }
     return Py_BuildValue("i", status);
 }
@@ -7158,5 +7229,5 @@
     unsigned options;
     pjsua_msg_data msg_data;
-	PyObject * omdObj;
+    PyObject * omdObj;
     msg_data_Object * omd;
     int user_data;
@@ -7172,6 +7243,7 @@
     dst_uri.ptr = PyString_AsString(sd);
     dst_uri.slen = strlen(PyString_AsString(sd));
-    if (omdObj != Py_None) {
-	omd = (msg_data_Object *)omdObj;
+    if (omdObj != Py_None) 
+    {
+        omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
         msg_data.content_type.slen = strlen
@@ -7179,5 +7251,5 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
         status = pjsua_call_make_call(acc_id, &dst_uri, 
@@ -7278,16 +7350,18 @@
         oi = (call_info_Object *)call_info_new(&call_info_Type, NULL, NULL);
         oi->acc_id = info.acc_id;
-	pj_ansi_snprintf(oi->buf_.call_id, sizeof(oi->buf_.call_id),
-			 "%.*s", (int)info.call_id.slen, info.call_id.ptr);
-	pj_ansi_snprintf(oi->buf_.last_status_text, sizeof(oi->buf_.last_status_text),
-			 "%.*s", (int)info.last_status_text.slen, info.last_status_text.ptr);
-	pj_ansi_snprintf(oi->buf_.local_contact, sizeof(oi->buf_.local_contact),
-			 "%.*s", (int)info.local_contact.slen, info.local_contact.ptr);
-	pj_ansi_snprintf(oi->buf_.local_info, sizeof(oi->buf_.local_info),
-			 "%.*s", (int)info.local_info.slen, info.local_info.ptr);
-	pj_ansi_snprintf(oi->buf_.remote_contact, sizeof(oi->buf_.remote_contact),
-			 "%.*s", (int)info.remote_contact.slen, info.remote_contact.ptr);
-	pj_ansi_snprintf(oi->buf_.remote_info, sizeof(oi->buf_.remote_info),
-			 "%.*s", (int)info.remote_info.slen, info.remote_info.ptr);
+        pj_ansi_snprintf(oi->buf_.call_id, sizeof(oi->buf_.call_id),
+	    "%.*s", (int)info.call_id.slen, info.call_id.ptr);
+        pj_ansi_snprintf(oi->buf_.last_status_text, 
+	    sizeof(oi->buf_.last_status_text),
+	    "%.*s", (int)info.last_status_text.slen, info.last_status_text.ptr);
+        pj_ansi_snprintf(oi->buf_.local_contact, sizeof(oi->buf_.local_contact),
+	    "%.*s", (int)info.local_contact.slen, info.local_contact.ptr);
+        pj_ansi_snprintf(oi->buf_.local_info, sizeof(oi->buf_.local_info),
+	    "%.*s", (int)info.local_info.slen, info.local_info.ptr);
+        pj_ansi_snprintf(oi->buf_.remote_contact,
+	    sizeof(oi->buf_.remote_contact),
+	    "%.*s", (int)info.remote_contact.slen, info.remote_contact.ptr);
+        pj_ansi_snprintf(oi->buf_.remote_info, sizeof(oi->buf_.remote_info),
+	    "%.*s", (int)info.remote_info.slen, info.remote_info.ptr);
 
         oi->call_id = PyString_FromStringAndSize(info.call_id.ptr, 
@@ -7374,9 +7448,9 @@
     int status;
     int call_id;
-    pj_str_t reason;
+    pj_str_t * reason;
     PyObject * sr;
     unsigned code;
     pjsua_msg_data msg_data;
-	PyObject * omdObj;
+    PyObject * omdObj;
     msg_data_Object * omd;    
     pj_pool_t * pool;
@@ -7386,8 +7460,14 @@
         return NULL;
     }
-
-    reason.ptr = PyString_AsString(sr);
-    reason.slen = strlen(PyString_AsString(sr));
-    if (omdObj != Py_None) {
+    if (sr == Py_None) 
+    {
+        reason = NULL;
+    } else {
+	reason = (pj_str_t *)malloc(sizeof(pj_str_t));
+        reason->ptr = PyString_AsString(sr);
+        reason->slen = strlen(PyString_AsString(sr));
+    }
+    if (omdObj != Py_None) 
+    {
         omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -7396,14 +7476,18 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
 	
-        status = pjsua_call_answer(call_id, code, &reason, &msg_data);	
+        status = pjsua_call_answer(call_id, code, reason, &msg_data);	
     
         pj_pool_release(pool);
     } else {
 	
-        status = pjsua_call_answer(call_id, code, &reason, NULL);	
-	}
+        status = pjsua_call_answer(call_id, code, reason, NULL);	
+    }
+    if (reason != NULL)
+    {
+        free(reason);
+    }
     return Py_BuildValue("i",status);
 }
@@ -7417,9 +7501,9 @@
     int status;
     int call_id;
-    pj_str_t reason;
+    pj_str_t * reason;
     PyObject * sr;
     unsigned code;
     pjsua_msg_data msg_data;
-	PyObject * omdObj;
+    PyObject * omdObj;
     msg_data_Object * omd;    
     pj_pool_t * pool = NULL;
@@ -7429,8 +7513,14 @@
         return NULL;
     }
-	
-    reason.ptr = PyString_AsString(sr);
-    reason.slen = strlen(PyString_AsString(sr));
-    if (omdObj != Py_None) {
+    if (sr != Py_None)
+    {
+        reason = NULL;
+    } else {
+        reason = (pj_str_t *)malloc(sizeof(pj_str_t));
+        reason->ptr = PyString_AsString(sr);
+        reason->slen = strlen(PyString_AsString(sr));
+    }
+    if (omdObj != Py_None) 
+    {
         omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -7439,10 +7529,14 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
-        status = pjsua_call_hangup(call_id, code, &reason, &msg_data);	
+        status = pjsua_call_hangup(call_id, code, reason, &msg_data);	
         pj_pool_release(pool);
     } else {
-        status = pjsua_call_hangup(call_id, code, &reason, NULL);	
+        status = pjsua_call_hangup(call_id, code, reason, NULL);	
+    }
+    if (reason != NULL)
+    {
+        free(reason);
     }
     return Py_BuildValue("i",status);
@@ -7467,5 +7561,6 @@
     }
 
-    if (omdObj != Py_None) {
+    if (omdObj != Py_None) 
+    {
         omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -7474,11 +7569,11 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
         status = pjsua_call_set_hold(call_id, &msg_data);	
         pj_pool_release(pool);
-	} else {
+    } else {
         status = pjsua_call_set_hold(call_id, NULL);	
-	}
+    }
     return Py_BuildValue("i",status);
 }
@@ -7504,5 +7599,5 @@
 
     if (omdObj != Py_None)
-	{
+    {
         omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -7511,5 +7606,5 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
         status = pjsua_call_reinvite(call_id, unhold, &msg_data);	
@@ -7545,5 +7640,5 @@
     
     if (omdObj != Py_None)
-	{
+    {
         omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -7552,11 +7647,11 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
         status = pjsua_call_xfer(call_id, &dest, &msg_data);	
         pj_pool_release(pool);
-	} else {
+    } else {
         status = pjsua_call_xfer(call_id, &dest, NULL);	
-	}
+    }
     return Py_BuildValue("i",status);
 }
@@ -7584,5 +7679,5 @@
 	
     if (omdObj != Py_None)
-	{
+    {
         omd = (msg_data_Object *)omdObj;    
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -7591,12 +7686,12 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
         status = pjsua_call_xfer_replaces
 			(call_id, dest_call_id, options, &msg_data);	
         pj_pool_release(pool);
-	} else {
+    } else {
         status = pjsua_call_xfer_replaces(call_id, dest_call_id,options, NULL);	
-	}
+    }
     return Py_BuildValue("i",status);
 }
@@ -7632,5 +7727,6 @@
     int status;
     int call_id;
-    pj_str_t mime_type, content;
+    pj_str_t content;
+    pj_str_t * mime_type;
     PyObject * sm;
     PyObject * sc;
@@ -7646,12 +7742,17 @@
         return NULL;
     }
-	
-    mime_type.ptr = PyString_AsString(sm);
-    mime_type.slen = strlen(PyString_AsString(sm));
+    if (sm == Py_None)
+    {
+        mime_type = NULL;
+    } else {
+        mime_type = (pj_str_t *)malloc(sizeof(pj_str_t));
+        mime_type->ptr = PyString_AsString(sm);
+        mime_type->slen = strlen(PyString_AsString(sm));
+    }
     content.ptr = PyString_AsString(sc);
     content.slen = strlen(PyString_AsString(sc));
     
     if (omdObj != Py_None)
-	{
+    {
         omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -7660,13 +7761,17 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
         status = pjsua_call_send_im
-			(call_id, &mime_type, &content, &msg_data, &user_data);	
+		(call_id, mime_type, &content, &msg_data, (void *)user_data);	
         pj_pool_release(pool);
-	} else {
+    } else {
         status = pjsua_call_send_im
-			(call_id, &mime_type, &content, NULL, &user_data);	
-	}
+			(call_id, mime_type, &content, NULL, (void *)user_data);	
+    }
+    if (mime_type != NULL)
+    {
+        free(mime_type);
+    }
     return Py_BuildValue("i",status);
 }
@@ -7692,5 +7797,5 @@
 	
     if (omdObj != Py_None)
-	{
+    {
         omd = (msg_data_Object *)omdObj;
         msg_data.content_type.ptr = PyString_AsString(omd->content_type);
@@ -7699,11 +7804,11 @@
         msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
         msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
-        pool = pjsua_pool_create("pjsua", 4000, 4000);
+        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
         translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
         status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data);	
         pj_pool_release(pool);
-	} else {
+    } else {
         status = pjsua_call_send_typing_ind(call_id, is_typing, NULL);	
-	}
+    }
     return Py_BuildValue("i",status);
 }
@@ -7751,4 +7856,5 @@
     status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent);
     sb = PyString_FromStringAndSize(buffer, maxlen);
+    free(buffer);
     return Py_BuildValue("O", sb);
 }
@@ -8016,4 +8122,8 @@
     },
     {
+        "buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS,
+        pjsua_buddy_config_default_doc
+    },
+    {
         "get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS,
         pjsua_get_buddy_count_doc
@@ -8026,5 +8136,5 @@
         "enum_buddies", py_pjsua_enum_buddies, METH_VARARGS,
         pjsua_enum_buddies_doc
-    },
+    },    
     {
         "buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS,
