diff --git a/drupalvb.admin-pages.inc b/drupalvb.admin-pages.inc
index 3fa493d..71d8ec7 100644
--- a/drupalvb.admin-pages.inc
+++ b/drupalvb.admin-pages.inc
@@ -88,11 +88,28 @@ function drupalvb_settings_integration() {
 /**
  * Settings form for remote system database connection.
  */
-function drupalvb_settings_database() {
+function drupalvb_settings_database($form, &$form_state) {
   $form = array();
-  $db_info = Database::getConnectionInfo();
-  $db = variable_get('drupalvb_db',array_shift($db_info));
-
+  $db = variable_get('drupalvb_db',array());
+  
+  if(count($db) == 0) {
+    $config = drupalvb_get_config();  // Get connection info from config
+    $fields = array(
+      "Database:dbtype" => "driver",
+      "Database:dbname" => "database",
+      "Database:tableprefix" => "db_prefix",
+      "MasterServer:servername" => "host",
+      "MasterServer:port" => "port",
+      "MasterServer:username" => "username",
+      "MasterServer:password" => "password",
+    );
+    foreach($fields as $vbfield => $field) {
+      $vv = explode(":",$vbfield);
+      $db[$field] = $config[$vv[0]][$vv[1]];
+    }
+    if(count($form_state['input']) == 0) drupal_set_message(t("Verify vb configuration and save form")); 
+  }
+  
   $form['db'] = array(
     '#type' => 'fieldset',
     '#title' => t('Database connection'),
@@ -102,8 +119,7 @@ function drupalvb_settings_database() {
     '#title' => t('Database interface'),
     '#options' => array('mysql' => 'MySQL', 'mysqli' => 'MySQLi'),
     '#default_value' => $db['driver'], 
-    '#disabled' => TRUE,
-    '#description' => t('Due to the database abstraction design in Drupal 5 and 6, only the current default database interface is supported.'),
+    '#disabled' => FALSE,
   );
   $form['db']['host'] = array(
     '#type' => 'textfield',
@@ -111,6 +127,12 @@ function drupalvb_settings_database() {
     '#default_value' => !empty($db['host']) ? $db['host'] : 'localhost',
     '#required' => TRUE,
   );
+  $form['db']['port'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Port'),
+    '#default_value' => !empty($db['port']) ? $db['port'] : 3306,
+    '#required' => TRUE,
+  );
   $form['db']['database'] = array(
     '#type' => 'textfield',
     '#title' => t('Database'),
@@ -142,20 +164,14 @@ function drupalvb_settings_database() {
 }
 
 function drupalvb_settings_database_submit($form, &$form_state) {
-  $initial_import = FALSE;
-  // If there is no database configuration yet, we want to execute an initial
-  // user import later.
-  if (!variable_get('drupalvb_db', 0)) {
-    $initial_import = TRUE;
-  }
-
   variable_set('drupalvb_db', $form_state['values']);
-  variable_set('drupalvb_db_prefix', $form_state['values']['db_prefix']);
 
   //Check database is ok
   drupalvb_db_connect();
-  drupalvb_db_disconnection();
-  if ($initial_import) {
+  drupalvb_db_disconnect();
+  
+  $mappings = db_query_range("SELECT uid FROM {drupalvb_users}",0,1);
+  if(count($mappings) == 0) {
     // First time setup; initialize DrupalvB's user mapping.
     module_load_include('inc', 'drupalvb');
     _drupalvb_init_user_map();
diff --git a/drupalvb.inc b/drupalvb.inc
index 8355d1b..844b3d3 100644
--- a/drupalvb.inc
+++ b/drupalvb.inc
@@ -28,7 +28,7 @@ function drupalvb_db_connect() {
 
     if(user_access('administer drupalvb')) {
       drupal_set_message(t('Invalid database connection for vBulletin. Please configure the connection in <a href="!settings">Drupal vB\'s settings</a>', array('!settings' => url('admin/settings/drupalvb/database'))), 'error');
-      drupal_goto('admin/settings/drupalvb/database');
+      drupal_goto('admin/config/system/drupalvb/database');
     } else {
        drupal_set_message(t('There was an error connecting to vBulletin. Please contact the site administrator.'), 'error');
     }
@@ -82,7 +82,8 @@ function drupalvb_db_is_valid() {
       'database' => $db['database'],
       'username' => $db['username'], 
       'password' => $db['password'],
-      'host' => $db['host'], 
+      'host' => $db['host'],
+      'port' => $db['port'], 
       'driver' => $db['driver'], 
       'prefix' => isset($db['db_prefix'])?$db['db_prefix']:'',
     );
@@ -175,7 +176,7 @@ function drupalvb_db_last_insert_id($table, $field) {
 function _drupalvb_init_user_map() {
   $users = $vbusers = array();
   // Fetch all users in Drupal.
-  $result = db_query("SELECT uid, name FROM {users}");
+  $result = db_query("SELECT uid, name FROM {users} WHERE uid>=1");
   foreach ($result as $user) {
     $users[$user->name] = $user->uid;
   }
@@ -183,9 +184,11 @@ function _drupalvb_init_user_map() {
   $result = drupalvb_db_query("SELECT userid, username FROM {user}");
   // Insert all vB users who already exist in Drupal with corresponding username
   // into our mapping table.
-  foreach ($result as $vb_user) {
+  foreach ($result as $vbuser) {
     if (isset($users[$vbuser->username])) {
-      db_query("INSERT INTO {drupalvb_users} (uid, userid) VALUES (:uid, :userid)", array(":uid"=>$users[$vbuser->username], ":userid"=>$vbuser->userid));
+      db_query("INSERT INTO {drupalvb_users} (uid, userid) 
+                VALUES (:uid, :userid)", 
+                array(":uid"=>$users[$vbuser->username], ":userid"=>$vbuser->userid));
     }
   }
 }
diff --git a/drupalvb.inc.php b/drupalvb.inc.php
index b2bd4bf..6e90ffd 100644
--- a/drupalvb.inc.php
+++ b/drupalvb.inc.php
@@ -313,7 +313,10 @@ function drupalvb_get_config() {
 
     // @todo Find & include vB's config automatically?
     // $files = file_scan_directory('.', '^config.php$', $nomask = array('.', '..', 'CVS', '.svn'));
-    $config_file = drupal_get_path('module', 'drupalvb') . '/config.php';
+    $config_file = './'. conf_path() .'/config.php';
+    if (!file_exists($config_file)) {
+      $config_file = drupal_get_path('module', 'drupalvb') . '/config.php';
+    }
     if (file_exists($config_file)) {
       require_once $config_file;
 
diff --git a/drupalvb.install b/drupalvb.install
index 4a0237b..4841c24 100644
--- a/drupalvb.install
+++ b/drupalvb.install
@@ -19,7 +19,7 @@ function drupalvb_requirements($phase) {
     $requirements['drupalvb']['severity'] = REQUIREMENT_ERROR;
     $requirements['drupalvb']['description'] = $t('The vBulletin configuration file <code>@filepath-vb</code> is required in <code>@filepath-drupalvb</code> (either as copy or soft link).', array(
       '@filepath-vb' => 'includes/config.php',
-      '@filepath-drupalvb' => drupal_get_path('module', 'drupalvb') . '/config.php',
+      '@filepath-drupalvb' => conf_path() .'/config.php or ' . drupal_get_path('module', 'drupalvb') . '/config.php',
     ));
   }
   return $requirements;
diff --git a/drupalvb.module b/drupalvb.module
index 5cbaee5..a596221 100644
--- a/drupalvb.module
+++ b/drupalvb.module
@@ -38,10 +38,10 @@ function drupalvb_theme() {
  */
 function drupalvb_help($path, $arg) {
   switch ($path) {
-    case 'admin/settings#description':
+    case 'admin/config/system#description':
       return t('Allows basic integration of Drupal with a vBulletin forum.');
 
-    case 'admin/settings/drupalvb':
+    case 'admin/config/system/drupalvb':
       module_load_include('inc', 'drupalvb');
       $vb_config = drupalvb_get('config');
       $vb_options = drupalvb_get('options');
@@ -71,26 +71,26 @@ function drupalvb_help($path, $arg) {
 function drupalvb_menu() {
   $items = array();
 
-  $items['admin/settings/drupalvb'] = array(
+  $items['admin/config/system/drupalvb'] = array(
     'title' => 'Drupal vB integration',
     'page callback' => 'drupalvb_settings',
     'page arguments' => array('integration'),
     'description' => 'Configure integration of Drupal with vBulletin forum.',
     'access arguments' => array('administer drupalvb'),
   );
-  $items['admin/settings/drupalvb/integration'] = array(
+  $items['admin/config/system/drupalvb/integration'] = array(
     'title' => 'Integration',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
-  $items['admin/settings/drupalvb/database'] = array(
+  $items['admin/config/system/drupalvb/database'] = array(
     'title' => 'Database',
     'page callback' => 'drupalvb_settings',
     'page arguments' => array('database'),
     'access arguments' => array('administer drupalvb'),
     'type' => MENU_LOCAL_TASK,
   );
-  $items['admin/settings/drupalvb/actions'] = array(
+  $items['admin/config/system/drupalvb/actions'] = array(
     'title' => 'Actions',
     'page callback' => 'drupalvb_settings',
     'page arguments' => array('actions'),
@@ -98,7 +98,7 @@ function drupalvb_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 10,
   );
-  $items['admin/settings/drupalvb/variables'] = array(
+  $items['admin/config/system/drupalvb/variables'] = array(
     'title' => 'Variables',
     'page callback' => 'drupalvb_settings',
     'page arguments' => array('variables'),
@@ -311,6 +311,17 @@ function drupalvb_vb_user_load($userid) {
 }
 
 /**
+ * Lookup a vBulletin user from the Drupal uid, using the mapping
+ * table.
+ *
+ * @param $uid
+ *   A Drupal uid.
+ */
+function drupalvb_get_userid($uid) {
+  return db_query("SELECT userid FROM {drupalvb_users} WHERE uid = :uid", array(":uid"=>$uid))->fetchField();
+}
+
+/**
  * Log in a user in vB upon login in Drupal.
  *
  * @see drupalvb_user()
@@ -350,18 +361,17 @@ $vbuser = drupalvb_db_query("SELECT u.userid, ub.liftdate FROM {user} u LEFT JOI
  * @see drupalvb_user()
  */
 function drupalvb_user_logout($account) {
-
   //A check must be made for database connectivity here, otherwise the logout
   //process will be stopped.
-  if(!drupalvb_db_connect()) {
+  if(!drupalvb_db_is_valid()) {
     watchdog('drupalvb', t('Forum session was NOT closed for user %username (@uid).', array('%username' => $account->name, '@uid' => $account->uid)), WATCHDOG_ERROR);
     return;
   } else {
-    $vbuser = drupalvb_db_query("SELECT userid, username FROM {user} WHERE username = :name", array(":name"=>drupalvb_htmlspecialchars($account->name)))->fetchAssoc();
-    if ($vbuser) {
+    $vbuserid = drupalvb_get_userid($account->uid);
+    if ($vbuserid) {
       // Remove all vB cookies for current user.
-      drupalvb_clear_cookies($vbuser['userid']);
-      watchdog('drupalvb', t('Forum session closed for user %username (@uid).', array('%username' => $vbuser['username'], '@uid' => $vbuser['userid'])));
+      drupalvb_clear_cookies($vbuserid);
+      watchdog('drupalvb', t('Forum session closed for user %username (@uid).', array('%username' => $account->name, '@uid' => $account->uid)));
     }
   }
 }
@@ -371,7 +381,7 @@ function drupalvb_user_logout($account) {
  */
 function drupalvb_user_presave(&$edit, $account) {
   $uid = isset($account->uid)?$account->uid:0;
-  $userid = db_query("SELECT userid FROM {drupalvb_users} WHERE uid = :uid", array(":uid" => $uid))->fetchField();
+  $userid = drupalvb_get_userid($uid);
   if(!$userid) {
     $userid = 0;
   }
@@ -806,7 +816,7 @@ function theme_drupalvb_block_recent($variables) {
  * Build data for recent posts by user block.
  */
 function drupalvb_block_recent_user($account) {
-  if ($vbuserid = db_query("SELECT userid FROM {drupalvb_users} WHERE uid = :uid", array(":uid" => $account->uid))->fetchField()) {
+  if ($vbuserid = drupalvb_get_userid($account->uid)) {
     $num_items  = variable_get('drupalvb_block_recent_count', 5);
     $vb_options = drupalvb_get('options');
     $result = drupalvb_db_query("SELECT p.postid, p.title, p.threadid, p.dateline AS created, p.userid, p.username AS name, t.title AS threadtitle, p.pagetext AS body FROM {post} p INNER JOIN {thread} t ON p.threadid = t.threadid INNER JOIN {forum} f ON f.forumid = t.forumid WHERE f.showprivate = 0 AND p.userid = :userid GROUP BY p.threadid ORDER BY p.dateline DESC LIMIT ".$num_items, array(":userid" => $vbuserid));
