diff --git a/profile2_regpath/profile2_regpath.install b/profile2_regpath/profile2_regpath.install
index 6b92dd5..bc60496 100644
--- a/profile2_regpath/profile2_regpath.install
+++ b/profile2_regpath/profile2_regpath.install
@@ -11,7 +11,26 @@
 function profile2_regpath_schema() {
   $schema['profile2_regpath'] = array(
     'description' => 'Stores registration path information for profile2 profiles',
+	'export' => array(
+      'key' => 'profile_type',
+      'key name' => 'Profile type',
+      'primary key' => 'profile_type',
+      'identifier' => 'regpath',
+       'api' => array(
+        'owner' => 'profile2_regpath',
+        'api' => 'profile2_regpath',  // Base name for api include files.
+        'minimum_version' => '1.6',
+        'current_version' => '1.6',
+      ),
+    ),
     'fields' => array(
+	 'profile_type' => array(
+        'description' => 'The {profile_type}.type of this profile.',
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'default' => '',
+      ),
       'profile_id' => array(
         'description' => 'Profile2 profile ID',
         'type' => 'int',
@@ -48,7 +67,7 @@ function profile2_regpath_schema() {
         'not null' => FALSE,
       ),
     ),
-    'primary key' => array('profile_id'),
+    'primary key' => array('profile_type'),
     'indexes' => array(
       'type' => array(array('path', 255)),
     ),
diff --git a/profile2_regpath/profile2_regpath.module b/profile2_regpath/profile2_regpath.module
index 4c2a2fe..207e964 100644
--- a/profile2_regpath/profile2_regpath.module
+++ b/profile2_regpath/profile2_regpath.module
@@ -80,7 +80,7 @@ function profile2_regpath_menu_alter(&$items) {
   if ($user_paths = profile2_regpath_get_profiles('user')) {
     // Build form at user/register using _profile2_regpath_user_register().
     $items['user/register']['page callback'] = '_profile2_regpath_user_register';
-    $items['user/register']['page arguments'] = array($user_paths[0]);
+    $items['user/register']['page arguments'] = array(current($user_paths));
     $items['user/register']['file'] = 'registration_form.inc';
     $items['user/register']['file path'] = drupal_get_path('module', 'profile2_regpath');
 
@@ -319,11 +319,18 @@ function profile2_regpath_save_settings($form, &$form_state) {
   ));
 
   // Add settings to database.
-  db_merge('profile2_regpath')
+  /*db_merge('profile2_regpath')
     ->key(array('profile_id' => $profile_id))
     ->fields($fields)
-    ->execute();
-
+    ->execute();*/
+  
+  $fields['profile_type'] = $profile_type;
+  $fields['profile_id'] = $profile_id;
+  $regpath = profile2_regpath_regpath_prepare();
+  $regpath = array_merge($regpath, $fields);
+  
+  profile2_regpath_regpath_save($regpath);
+  
   // Build array of form elements to check for new values.
   $changed_check = array(
     array(
@@ -473,21 +480,89 @@ function _get_profile_types_by_path() {
  *   profile types.
  */
 function profile2_regpath_get_profiles($path = NULL, $groupby = NULL) {
-  // Get data object of all registration paths.
-  $query = db_select('profile2_regpath', 'pr');
-  $query->join('profile_type', 'pt', 'pr.profile_id = pt.id');
-  $query->fields('pr', array('path', 'roles', 'misc', 'status'));
-  $query->fields('pt', array('id', 'label', 'type'));
+  $profiles = profile2_regpath_regpath_load_all();
   if ($path) {
-    $query->condition('path', $path);
+    array_walk($profiles, '_attribute_filter', array('path', $path));
+    $profiles = array_filter($profiles);
   }
-  if ($groupby) {
-    $query->groupBy($groupby);
+  array_walk($profiles, '_attribute_filter', array('status', 1));
+  $profiles = array_filter($profiles);
+  array_walk($profiles, '_attribute_label');
+  uasort($profiles, '_weight_order');
+  return $profiles;
+}
+
+/**
+ * Implements 'load callback' for myobj exportables
+ */
+function profile2_regpath_regpath_load($profile_type) {
+  ctools_include('export');
+  $result = ctools_export_load_object('profile2_regpath', 'names', array($profile_type));
+  if (isset($result[$profile_type])) {
+    return $result[$profile_type];
   }
-  $query->condition('pr.status', 1);
-  $query->orderBy('pr.weight', 'ASC');
-  $result = $query->execute();
-  $profile_types = $result->fetchAll();
+}
 
-  return $profile_types;
+/**
+ * Implements 'load multiple callback' for myobj exportables.
+ */
+function profile2_regpath_regpath_load_multiple(array $profile_types) {
+  ctools_include('export');
+  $results = ctools_export_load_object('profile2_regpath', 'names', $profile_types);
+  return array_filter($results);
+}
+
+/**
+ * Implements 'load all callback' for myobj exportables.
+ */
+function profile2_regpath_regpath_load_all() {
+  ctools_include('export');
+  $results = ctools_export_load_object('profile2_regpath');
+  return array_filter($results);
+}
+
+/**
+ * Save a single myobj.
+ */
+function profile2_regpath_regpath_save(&$regpath) {
+  $exist = profile2_regpath_regpath_load($regpath['profile_type']);
+  $update = 'profile_type';
+  if (is_null($exist)) {
+    $update = array();
+  }
+  return drupal_write_record('profile2_regpath', $regpath, $update);
+}
+
+/**
+ * prepare a regpath obj 
+ */
+function profile2_regpath_regpath_prepare() {
+  $schema = drupal_get_schema('profile2_regpath');
+  $fields = array_keys($schema['fields']);
+  return array_fill_keys($fields, null);
+}
+
+/**
+ *
+ */
+function _attribute_label(&$item, $key) {
+  $profile_type = profile2_type_load($item->profile_type);
+  $item->label = $profile_type ? $profile_type->label : '';
+}
+
+/**
+ *
+ */
+function _attribute_filter(&$item, $key, array $params) {
+  list($attribute, $needle) = $params;
+  if ($item->{$attribute} != $needle) {
+    $item = null;
+  }
+}
+
+/**
+ *
+ */
+function _weight_order($a, $b) {
+  return $a->weight > $b->weight ? true : false;
 }
\ No newline at end of file
