diff --git a/flattrblock.install b/flattrblock.install
index fb8f426..6267d5a 100644
--- a/flattrblock.install
+++ b/flattrblock.install
@@ -5,6 +5,39 @@
  */
 
 /**
+ * Implements hook_schema().
+ */
+function flattrblock_schema() {
+  $schema['flattrblock'] = array(
+    'description' => 'flattrblock blocks',
+    'fields' => array(
+      'fsid' => array(
+        'description' => 'Block ID.',
+        'type' => 'serial',
+      ),
+      'name' => array(
+        'description' => 'flattrblock block name.',
+        'type' => 'text',
+        'size' => 'small',
+        'not null' => TRUE,
+      ),
+      'flattrblock_options' => array(
+        'description' => 'Options for flattrblock',
+        'type' => 'blob',
+        'size' => 'big',
+        'not null' => FALSE,
+        'serialize' => TRUE,
+      ),
+    ),
+    'primary key' => array(
+      'fsid',
+    ),
+  );
+  return $schema;
+}
+
+
+/**
  * Implements hook_uninstall().
  */
 function flattrblock_uninstall() {
diff --git a/flattrblock.module b/flattrblock.module
index de68aa5..35cd5d9 100644
--- a/flattrblock.module
+++ b/flattrblock.module
@@ -7,15 +7,87 @@
  * provide block with configform and load script
  */
 
+
 /**
- * Implements hook_block_info().
+ * Implements hook_permission().
  */
-function flattrblock_block_info() {
-  $blocks['flattrblock'] = array(
-    'info' => t('flattrblock'),
-    'cache' => DRUPAL_NO_CACHE,
+function flattrblock_permission() {
+  return array(
+    'administer flattrblock' => array(
+      'title' => t('Administer flattrblock Blocks'),
+    ),
+  );
+}
+
+/**
+ * Implements hook_menu().
+ */
+function flattrblock_menu() {
+  // Admin  menu item.
+  $items['admin/structure/flattrblock'] = array(
+    'title' => 'flattrblock Blocks',
+    'description' => 'Create Flexslider  Blocks.',
+    'page callback' => 'flattrblock_admin_page',
+    'file' => 'includes/flattrblock.admin.inc',
+    'access arguments' => array(
+      'administer flattrblock',
+    ),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => 10,
   );
+  return $items;
+}
 
+
+/**
+ * Query blocks lists.
+ *
+ * @param int $id
+ *   optional user id
+ *
+ * @return array
+ *   An array of user ids and their lists.
+ */
+function flattrblock_block_query($id = FALSE) {
+  $result = db_select('flattrblock', 'of')->fields('of');
+  if ($id) {
+    $result->condition('fsid', $id, '=');
+  }
+  $results = $result->execute();
+  return $results;
+}
+
+/**
+ * flattrblock_block_choices.
+ *
+ * @access public
+ * @return array
+ *   array of oms blocks
+ */
+function flattrblock_block_choices() {
+  $results = array();
+  $flattrblock_blocks = flattrblock_block_query();
+  foreach ($flattrblock_blocks as $flattrblock_block) {
+    $results[$flattrblock_block->fsid] = $flattrblock_block->name;
+  }
+  return $results;
+}
+
+
+/**
+ * Implements hook_block_info().
+ */
+function flattrblock_block_info() {
+  $blocks = array();
+  $flattrblock_blocks = flattrblock_block_query();
+  foreach ($flattrblock_blocks as $flattrblock_block) {
+    $blocks[($flattrblock_block->fsid)] = array(
+      'info' => t('Flattr Block:@name', array('@name' => $flattrblock_block->name)),
+      'cache' => DRUPAL_NO_CACHE,
+      'status' => 1,
+      'region' => -1,
+    );
+  }
   return $blocks;
 }
 
@@ -26,33 +98,8 @@ function flattrblock_block_configure($delta = '') {
   // The $delta parameter tells us which block is being configured.
   // In this example, we'll allow the administrator to customize
   // the text of the 'configurable text string' block defined in this module.
-  $form = array();
-  if ($delta == 'flattrblock') {
-    // All we need to provide is the specific configuration options for our
-    // block. Drupal will take care of the standard block configuration options
-    // (block title, page visibility, etc.) and the save button.
-    $form['flattrblock_username'] = array(
-      '#type' => 'textfield',
-      '#title' => t('username'),
-      '#size' => 60,
-      '#description' => t('username to use for site flattr'),
-      '#default_value' => variable_get('flattrblock_username', t('none set.')),
-    );
-    $form['flattrblock_categories'] = array(
-      '#type' => 'textfield',
-      '#title' => t('category'),
-      '#size' => 60,
-      '#description' => t('category to use for site flattr'),
-      '#default_value' => variable_get('flattrblock_categories', t('none set.')),
-    );
-    $form['flattrblock_tags'] = array(
-      '#type' => 'textfield',
-      '#title' => t('tags'),
-      '#size' => 60,
-      '#description' => t('tags to use for site flattr'),
-      '#default_value' => variable_get('flattrblock_tags', t('none set.')),
-    );
-  }
+  include 'includes/flattrblock.block_form.inc';
+  $form = flattrblock_block_configure_form($delta);
   return $form;
 }
 
@@ -61,8 +108,8 @@ function flattrblock_block_configure($delta = '') {
  */
 function flattrblock_block_view($delta = '') {
   // The $delta parameter tells us which block is being requested.
-  switch ($delta) {
-    case 'flattrblock':
+  //switch ($delta) {
+    //case 'flattrblock':
       // The subject is displayed at the top of the block. Note that it
       // should be passed through t() for translation. The title configured
       // for the block using Drupal UI supercedes this one.
@@ -71,30 +118,41 @@ function flattrblock_block_view($delta = '') {
       // function.
       $block['content'] = flattrblock_contents($delta);
 
-      break;
+     // break;
 
-  }
+  //}
   return $block;
 }
 /**
  * Attach flattr script to block.
  */
-function flattrblock_contents($which_block) {
+function flattrblock_contents($delta) {
+$variables = array();
+  // get the settings for this block
+  $results = flattrblock_block_query($delta);
+  if ($results) {
+  
+  foreach ($results as $record) {
+    // unserialize the settings
+    $values = unserialize($record->flattrblock_options);
+    //set variables for theme function
+    foreach ($values as $key => $value) {
+    $variables['flattrblock_' . $key] = $value;
+    
+    }
+  }
+  }
 
-  switch ($which_block) {
-    case 'flattrblock':
+ // switch ($which_block) {
+   // case 'flattrblock':
       // Passing the site url for building the link,
       global $base_url;
-      $site_name = variable_get('site_name');
-      $flattrblock_username = variable_get('flattrblock_username');
-      $flattrblock_categories = variable_get('flattrblock_categories');
-      $flattrblock_tags = variable_get('flattrblock_tags');
-      $variables = array();
+      
       $variables['site_url'] = $base_url;
-      $variables['site_name'] = $site_name;
-      $variables['flattrblock_username'] = $flattrblock_username;
-      $variables['flattrblock_categories'] = $flattrblock_categories;
-      $variables['flattrblock_tags'] = $flattrblock_tags;
+      $variables['site_name'] = variable_get('site_name');
+//      $variables['flattrblock_username'] = variable_get('flattrblock_username');
+//      $variables['flattrblock_categories'] = variable_get('flattrblock_categories');
+//      $variables['flattrblock_tags'] = variable_get('flattrblock_tags');
       $block_content = array(
         '#markup' => theme('flattrblock_link', $variables),
       );
@@ -112,7 +170,7 @@ function flattrblock_contents($which_block) {
         $flattrblock_js_attached = TRUE;
       }
       return $block_content;
-  }
+ // }
 }
 
 
@@ -186,14 +244,30 @@ function _flattrblock_attributes($attributes) {
  * Implements hook_block_save().
  */
 function flattrblock_block_save($delta = '', $edit = array()) {
+  foreach ($edit as $key => $value) {
+
+    // If this is one of our settings
+    $flattrtest = strpos($key, 'flattrblock_');
+    if ($flattrtest !== FALSE) {
+        // split up the settings
+        $flattrkey = str_replace('flattrblock_', '', $key);
+        $options[$flattrkey] = $value;
+
+       }
 
+  }
+  
+ db_update('flattrblock')->fields(array(
+    'flattrblock_options' => serialize($options),
+  ))->condition('fsid', $delta)->execute();
+ 
   // We need to save settings from the configuration form.
   // We need to check $delta to make sure we are saving the right block.
-  if ($delta == 'flattrblock') {
-    // Have Drupal save the string to the database.
-    variable_set('flattrblock_username', $edit['flattrblock_username']);
-    variable_set('flattrblock_categories', $edit['flattrblock_categories']);
-    variable_set('flattrblock_tags', $edit['flattrblock_tags']);
-  }
+  //if ($delta == 'flattrblock') {
+    // Have Drupal save the settings to the database.
+    //variable_set('flattrblock_username', $edit['flattrblock_username']);
+   // variable_set('flattrblock_categories', $edit['flattrblock_categories']);
+   // variable_set('flattrblock_tags', $edit['flattrblock_tags']);
+  //}
   // return;
 }
diff --git a/includes/flattrblock.admin.inc b/includes/flattrblock.admin.inc
new file mode 100644
index 0000000..cf79063
--- /dev/null
+++ b/includes/flattrblock.admin.inc
@@ -0,0 +1,131 @@
+<?php
+/**
+ * @file
+ * OMS Flexflattrblock module admin settings.
+ */
+
+/**
+ * Wrapper function to make page with table and form.
+ *
+ * @return string
+ *   html content
+ */
+function flattrblock_admin_page() {
+  $page = flattrblock_admin_table();
+  $page .= drupal_render(drupal_get_form('flattrblock_admin_create_form'));
+  return $page;
+}
+
+/**
+ * flattrblock_admin_create_form.
+ *
+ * @access public
+ * @return array
+ *   form array
+ */
+function flattrblock_admin_create_form() {
+  $form['flattrblock_create_block_name'] = array(
+    '#type' => 'textfield',
+  );
+  $form['flattrblock_create_block'] = array(
+    '#type' => 'submit',
+    '#value' => t('Create New Block'),
+    '#submit' => array(
+      'flattrblock_new_block',
+    ),
+  );
+  return $form;
+}
+
+/**
+ * flattrblock_admin_delete_form.
+ *
+ * @param mixed $block_id
+ *   block delta
+ *
+ * @access public
+ * @return array
+ *   form array
+ */
+function flattrblock_admin_delete_form($form, &$form_state, $block_id) {
+  $form['flattrblock_delete_block'] = array(
+    '#type' => 'submit',
+    '#value' => t('Delete Block'),
+    '#submit' => array(
+      'flattrblock_delete_block',
+    ),
+  );
+  $form['flattrblock_delete_block_id'] = array(
+    '#type' => 'hidden',
+    '#value' => ($block_id),
+  );
+  return $form;
+}
+
+
+/**
+ * Creates a table of all OMS Flexflattrblock blocks.
+ *
+ * @return form
+ *   A table of blocks with an add more form.
+ */
+function flattrblock_admin_table() {
+  global $base_url;
+  $results = flattrblock_block_query();
+  $rows = array();
+  foreach ($results as $record) {
+    $rows[] = array(
+      '<a href="' . $base_url . '/admin/structure/block/manage/flattrblock/' . $record->fsid . '/configure">' . $record->name . '</a>',
+      drupal_render(drupal_get_form('flattrblock_admin_delete_form', $record->fsid)),
+    );
+  }
+  $output = array(
+    'header' => array(
+      t('Block Name'),
+      t('Delete Block'),
+    ),
+    'rows' => $rows,
+  );
+  return theme('table', $output);
+}
+
+/**
+ * flattrblock_new_block.
+ *
+ * @param mixed $form
+ *   form
+ * @param mixed $form_state
+ *   form state
+ *
+ * @access public
+ */
+function flattrblock_new_block($form, &$form_state) {
+  $flattrdefaults = array(
+    'flattrblock_username' => 'none',
+    'flattrblock_categories' => 'none',
+    'flattrblock_tags' => 'none',
+  );
+  
+  $new_block = $form['flattrblock_create_block_name']['#value'];
+  db_insert('flattrblock')->fields(array(
+    'name' => $new_block,
+    'flattrblock_options' => serialize($flattrdefaults),
+  ))->execute();
+}
+
+
+/**
+ * flattrblock_delete_block.
+ *
+ * @param mixed $form
+ *   form
+ * @param mixed $form_state
+ *   form state
+ *
+ * @access public
+ */
+function flattrblock_delete_block($form, &$form_state) {
+  $block_id = $form['flattrblock_delete_block_id']['#value'];
+  db_delete('flattrblock')->condition('fsid', $block_id)->execute();
+}
+
diff --git a/includes/flattrblock.block_form.inc b/includes/flattrblock.block_form.inc
new file mode 100644
index 0000000..29a04cc
--- /dev/null
+++ b/includes/flattrblock.block_form.inc
@@ -0,0 +1,55 @@
+<?php
+/**
+ * @file
+ * Orbit Media Flexflattrblock Block configuration.
+ */
+
+/**
+ * flattrblock_block_configure_form.
+ *
+ * @access public
+ * @return array
+ *   form array
+ */
+function flattrblock_block_configure_form($delta) {
+ // All we need to provide is the specific configuration options for our
+  // block. Drupal will take care of the standard block configuration options
+  // (block title, page visibility, etc.) and the save button.
+  $form['flattrblock_username'] = array(
+    '#type' => 'textfield',
+    '#title' => t('username'),
+    '#size' => 60,
+    '#description' => t('username to use for site flattr'),
+  //  '#default_value' => variable_get('flattrblock_username', t('none set.')),
+  );
+  $form['flattrblock_categories'] = array(
+    '#type' => 'textfield',
+    '#title' => t('category'),
+    '#size' => 60,
+    '#description' => t('category to use for site flattr'),
+   // '#default_value' => variable_get('flattrblock_categories', t('none set.')),
+  );
+  $form['flattrblock_tags'] = array(
+    '#type' => 'textfield',
+    '#title' => t('tags'),
+    '#size' => 60,
+    '#description' => t('tags to use for site flattr'),
+   // '#default_value' => variable_get('flattrblock_tags', t('none set.')),
+  );
+
+  $results = flattrblock_block_query($delta);
+  if ($results) {
+  
+  foreach ($results as $record) {
+
+    $values = unserialize($record->flattrblock_options);
+
+    foreach ($values as $key => $value) {
+    $form['flattrblock_' . $key]['#default_value'] = $value;
+    
+    }
+  }
+  }
+  return $form;
+}
+
