diff --git a/src/modules/db_perlvdb/README b/src/modules/db_perlvdb/README
index ba746b7..83eca6b 100644
--- a/src/modules/db_perlvdb/README
+++ b/src/modules/db_perlvdb/README
@@ -69,12 +69,12 @@ Chapter 1. Admin Guide
    database access. Relaying of insert, update, query and delete
    operations is supported.
 
-   Modules can be configured to use the perlvdb module as database backend
+   Modules can be configured to use the db_perlvdb module as database backend
    using the db_url_parameter:
 modparam("acc", "db_url", "perlvdb:Kamailio::VDB::Adapter::AccountingSIPtrace")
 
    This configuration options tells acc module that it should use the
-   perlvdb module which will in turn use the Perl class
+   db_perlvdb module which will in turn use the Perl class
    Kamailio::VDB::Adapter::AccountingSIPtrace to relay the database
    requests.
 
@@ -86,13 +86,13 @@ modparam("acc", "db_url", "perlvdb:Kamailio::VDB::Adapter::AccountingSIPtrace")
 2.1. Kamailio Modules
 
    The following modules must be loaded before this module:
-     * perl -- Perl module
+     * app_perl -- Perl Application module
 
 2.2. External Libraries or Applications
 
    The following libraries or applications must be installed before
    running Kamailio with this module loaded:
-     * None (Besides the ones mentioned in the perl module documentation).
+     * None (Besides the ones mentioned in the app_perl module documentation).
 
 3. Parameters
 
@@ -136,7 +136,7 @@ Chapter 2. Developer Guide
 
 2. Base class Kamailio::VDB
 
-   A client module has to be configured to use the perlvdb module in
+   A client module has to be configured to use the db_perlvdb module in
    conjunction with a Perl class to provide the functions. The configured
    class needs to inherit from the base class Kamailio::VDB.
 
diff --git a/src/modules/db_perlvdb/doc/db_perlvdb_admin.xml b/src/modules/db_perlvdb/doc/db_perlvdb_admin.xml
index 1246815..87ca9b5 100644
--- a/src/modules/db_perlvdb/doc/db_perlvdb_admin.xml
+++ b/src/modules/db_perlvdb/doc/db_perlvdb_admin.xml
@@ -31,7 +31,7 @@
 		operations is supported.
 	</para>
 	<para>
-		Modules can be configured to use the perlvdb module as
+		Modules can be configured to use the db_perlvdb module as
 		database backend using the db_url_parameter:
 	</para>
 	<programlisting>
@@ -39,7 +39,7 @@ modparam("acc", "db_url", "perlvdb:Kamailio::VDB::Adapter::AccountingSIPtrace")
 </programlisting>
 	<para>
 		This configuration options tells acc module that it should use the
-		perlvdb module which will in turn use the Perl class
+		db_perlvdb module which will in turn use the Perl class
 		Kamailio::VDB::Adapter::AccountingSIPtrace
 		to relay the database requests.
 	</para>
@@ -53,7 +53,7 @@ modparam("acc", "db_url", "perlvdb:Kamailio::VDB::Adapter::AccountingSIPtrace")
 		The following  modules must be loaded before this module:
 			<itemizedlist>
 			<listitem>
-				<para><emphasis>perl</emphasis> -- Perl module</para>
+				<para><emphasis>app_perl</emphasis> -- Perl Application module</para>
 			</listitem>
 			</itemizedlist>
 		</para>
@@ -66,7 +66,7 @@ modparam("acc", "db_url", "perlvdb:Kamailio::VDB::Adapter::AccountingSIPtrace")
 			<itemizedlist>
 			<listitem>
 			<para>
-				<emphasis>None</emphasis> (Besides the ones mentioned in the perl
+				<emphasis>None</emphasis> (Besides the ones mentioned in the app_perl
 				module documentation).
 			</para>
 			</listitem>
diff --git a/src/modules/db_perlvdb/doc/db_perlvdb_devel.xml b/src/modules/db_perlvdb/doc/db_perlvdb_devel.xml
index b6f8e7d..5ed5b07 100644
--- a/src/modules/db_perlvdb/doc/db_perlvdb_devel.xml
+++ b/src/modules/db_perlvdb/doc/db_perlvdb_devel.xml
@@ -30,7 +30,7 @@
 	</section>
 	<section><title>Base class Kamailio::VDB</title>
 		<para>
-			A client module has to be configured to use the perlvdb module in conjunction
+			A client module has to be configured to use the db_perlvdb module in conjunction
 			with a Perl class to provide the functions. The configured class needs to
 			inherit from the base class <literal role="code">Kamailio::VDB</literal>.
 		</para>
diff --git a/src/modules/db_perlvdb/perlvdb_conv.c b/src/modules/db_perlvdb/perlvdb_conv.c
index c3f1e68..d14b48f 100644
--- a/src/modules/db_perlvdb/perlvdb_conv.c
+++ b/src/modules/db_perlvdb/perlvdb_conv.c
@@ -33,7 +33,7 @@
 /* Converts a set of pairs to perl SVs.
  * For insert, and update (second half)
  */
-AV *pairs2perlarray(db_key_t* keys, db_val_t* vals, int n) {
+AV *pairs2perlarray(const db_key_t* keys, const db_val_t* vals, const int n) {
 
 	AV *array = newAV();
 	SV *element;
@@ -50,7 +50,7 @@ AV *pairs2perlarray(db_key_t* keys, db_val_t* vals, int n) {
 /* Converts a set of cond's to perl SVs.
  * For delete, update (first half), query
  */
-AV *conds2perlarray(db_key_t* keys, db_op_t* ops, db_val_t* vals, int n) {
+AV *conds2perlarray(const db_key_t* keys, const db_op_t* ops, const db_val_t* vals, const int n) {
 	AV *array = newAV();
 	SV *element = NULL;
 	int i = 0;
@@ -80,7 +80,7 @@ AV *conds2perlarray(db_key_t* keys, db_op_t* ops, db_val_t* vals, int n) {
 /* Converts a set of key names to a perl array.
  * Needed in query.
  */
-AV *keys2perlarray(db_key_t* keys, int n) {
+AV *keys2perlarray(const db_key_t* keys, const int n) {
 	AV *array = newAV();
 	SV *element;
 	int i;
@@ -92,7 +92,7 @@ AV *keys2perlarray(db_key_t* keys, int n) {
 	return array;
 }
 
-SV *valdata(db_val_t* val) {
+SV *valdata(const db_val_t* val) {
 	SV *data = &PL_sv_undef;
 	const char* stringval;
 
@@ -148,7 +148,7 @@ SV *valdata(db_val_t* val) {
 	return data;
 }
 
-SV *val2perlval(db_val_t* val) {
+SV *val2perlval(const db_val_t* val) {
 	SV* retval;
 	SV *class;
 
@@ -167,7 +167,7 @@ SV *val2perlval(db_val_t* val) {
 
 }
 
-SV *pair2perlpair(db_key_t key, db_val_t* val) {
+SV *pair2perlpair(const db_key_t key, const db_val_t* val) {
 	SV* retval;
 	SV *class;
 
@@ -190,7 +190,7 @@ SV *pair2perlpair(db_key_t key, db_val_t* val) {
 	
 }
 
-SV *cond2perlcond(db_key_t key, db_op_t op, db_val_t* val) {
+SV *cond2perlcond(const db_key_t key, const db_op_t op, const db_val_t* val) {
 	SV* retval;
 	SV *class;
 	
@@ -290,11 +290,9 @@ int perlresult2dbres(SV *perlres, db1_res_t **r) {
 		currentstring = SvPV(d1, len);
 		charbuf = pkg_malloc(len+1);
 		strncpy(charbuf, currentstring, len+1);
-		(*r)->col.names[i]->s = charbuf;
-		(*r)->col.names[i]->len = strlen(charbuf);
+		(*r)->col.names[i] = (db_key_t)charbuf;
 
 		SvREFCNT_dec(d1);
-
 	}
 
 	rowarrayref = perlvdb_perlmethod(perlres, PERL_VDB_ROWSMETHOD,
@@ -405,8 +403,8 @@ int perlresult2dbres(SV *perlres, db1_res_t **r) {
 	}
 
 end:
-	av_undef(colarray);
-	av_undef(rowarray);
+	if (colarray) av_undef(colarray);
+	if (rowarray) av_undef(rowarray);
 	return retval;
 error:
 	LM_CRIT("broken result set. Exiting, leaving Kamailio in unknown state.\n");
diff --git a/src/modules/db_perlvdb/perlvdb_conv.h b/src/modules/db_perlvdb/perlvdb_conv.h
index 9018305..50ad626 100644
--- a/src/modules/db_perlvdb/perlvdb_conv.h
+++ b/src/modules/db_perlvdb/perlvdb_conv.h
@@ -44,21 +44,21 @@
 /* Converts a set of pairs to perl SVs.
  * For insert, and update (second half)
  */
-AV *pairs2perlarray(db_key_t* keys, db_val_t* vals, int n);
+AV *pairs2perlarray(const db_key_t* keys, const db_val_t* vals, const int n);
 
 /* Converts a set of cond's to perl SVs.
  * For delete, update (first half), query
  */
-AV *conds2perlarray(db_key_t* keys, db_op_t* ops, db_val_t* vals, int n);
+AV *conds2perlarray(const db_key_t* keys, const db_op_t* ops, const db_val_t* vals, const int n);
 
 /* Converts a set of key names to a perl array.
  * Needed in query.
  */
-AV *keys2perlarray(db_key_t* keys, int n);
+AV *keys2perlarray(const db_key_t* keys, const int n);
 
-SV *val2perlval(db_val_t* val);
-SV *pair2perlpair(db_key_t key, db_val_t* val);
-SV *cond2perlcond(db_key_t key, db_op_t op, db_val_t* val);
+SV *val2perlval(const db_val_t* val);
+SV *pair2perlpair(const db_key_t key, const db_val_t* val);
+SV *cond2perlcond(const db_key_t key, const db_op_t op, const db_val_t* val);
 
 int perlresult2dbres(SV *perlres, db1_res_t **r);
 
diff --git a/src/modules/db_perlvdb/perlvdbfunc.c b/src/modules/db_perlvdb/perlvdbfunc.c
index 73a7b1c..c6d6513 100644
--- a/src/modules/db_perlvdb/perlvdbfunc.c
+++ b/src/modules/db_perlvdb/perlvdbfunc.c
@@ -76,7 +76,7 @@ SV *newvdbobj(const char* cn) {
 	return obj;
 }
 
-SV *getobj(db1_con_t *con) {
+SV *getobj(const db1_con_t *con) {
 	return ((SV*)CON_TAIL(con));
 }
 
@@ -179,8 +179,8 @@ void perlvdb_db_close(db1_con_t* h) {
  * v: values of the keys
  * n: number of key=value pairs
  */
-int perlvdb_db_insertreplace(db1_con_t* h, db_key_t* k, db_val_t* v,
-		int n, char *insertreplace) {
+int perlvdb_db_insertreplace(const db1_con_t* h, const db_key_t* k, const db_val_t* v,
+		const int n, char *insertreplace) {
 	AV *arr;
 	SV *arrref;
 	SV *ret;
@@ -202,7 +202,7 @@ int perlvdb_db_insert(const db1_con_t* h, const db_key_t* k, const db_val_t* v,
 /*
  * Just like insert, but replace the row if it exists
  */
-int perlvdb_db_replace(db1_con_t* h, db_key_t* k, db_val_t* v, int n) {
+int perlvdb_db_replace(const db1_con_t* h, const db_key_t* k, const db_val_t* v, const int n) {
 	return perlvdb_db_insertreplace(h, k, v, n, PERL_VDB_REPLACEMETHOD);
 }
 
diff --git a/src/modules/db_perlvdb/perlvdbfunc.h b/src/modules/db_perlvdb/perlvdbfunc.h
index 5c09fac..33f392b 100644
--- a/src/modules/db_perlvdb/perlvdbfunc.h
+++ b/src/modules/db_perlvdb/perlvdbfunc.h
@@ -48,7 +48,7 @@ void perlvdb_db_close(db1_con_t* h);
 int perlvdb_use_table(db1_con_t* h, const str* t);
 
 int perlvdb_db_insert(const db1_con_t* h, const db_key_t* k, const db_val_t* v, const int n);
-int perlvdb_db_replace(db1_con_t* h, db_key_t* k, db_val_t* v, int n);
+int perlvdb_db_replace(const db1_con_t* h, const db_key_t* k, const db_val_t* v, const int n);
 int perlvdb_db_delete(const db1_con_t* h, const db_key_t* k, const db_op_t* o,
 		const db_val_t* v, const int n);
 int perlvdb_db_update(const db1_con_t* h, const db_key_t* k, const db_op_t* o,
