diff --git a/CHANGELOG.txt b/CHANGELOG.txt
deleted file mode 100644
index 0d74851..0000000
--- a/CHANGELOG.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-2009-02-07
- - Added: POT file.
- - Committed version 1.0
-
-2009-02-04
- - Fixed: A bug causing IMCE "Browse..." button not to show due to checking for
-   a non-existing permission.
- - Added: Improved installer that keeps track of dependencies without limiting
-   the site admin's options with regards to altering button icons and titles.
-
-2009-02-02b:
- - Fixed: Inline links do not require text to be previously selected for them 
-   to have text, they can now be created without any pre-typed link text.
- - Fixed: IMCE file browser dialog now opens when clicking "Browse...".
- - Added: Installer now updates button JS code in case the site path changes
-   or the module configuration changes in a way that affects Markdown Editor.
-
-2009-02-02
- - Added: Manual import of the button CSV file is no longer required, the
-   module installer handles everything.
- - Fixed: Updated CSS to work with new BUE dialog markup.
-
-2009-02-01
- - Added #360297 by ciberligre: Inline links are now supported
\ No newline at end of file
diff --git a/INSTALL.txt b/INSTALL.txt
index 549c1d3..9f2e26c 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -12,11 +12,11 @@ steps:
 3. Install the module as you would any other.
 
 4. Customize the editor and set up what roles may use it:
-   admin/settings/bueditor
- 
-You can customize the editor, use other icons or captions if you like. 
+   admin/config/content/bueditor
+
+You can customize the editor, use other icons or captions if you like.
 See the BUEditor readme file for a comprehensive guide to how you can
-customize the Markdown Editor button bar. 
+customize the Markdown Editor button bar.
 
 +-------------------------------------------------------------------------+
 | ############################## WARNING ################################ |
@@ -25,14 +25,14 @@ customize the Markdown Editor button bar.
 | you have uninstalled Markdown Editor you can restore your buttons using |
 | the CSV file you saved.                                                 |
 | How this is done is explained in the BUEditor readme file.              |
-+-------------------------------------------------------------------------+ 
- 
++-------------------------------------------------------------------------+
+
 To uninstall:
-   
+
 1. Uncheck the module on the modules page
    admin/build/modules
    to disable it
-   
+
 2. Go to
    admin/build/modules/uninstall
    to uninstall the module. UNINSTALLING MARKDOWN EDITOR WILL REMOVE
diff --git a/bueditor.buttons.txt b/bueditor.buttons.txt
new file mode 100644
index 0000000..8b55028
--- /dev/null
+++ b/bueditor.buttons.txt
@@ -0,0 +1,157 @@
+array (
+  'buttons' => 
+  array (
+    0 => 
+    array (
+      'title' => 'Make selected text into a header',
+      'content' => 'js:  markdownEditor.header();',
+      'icon' => 'md-make-header.gif',
+      'accesskey' => '',
+      'weight' => '0',
+    ),
+    1 => 
+    array (
+      'title' => 'Italics: Make selected text emphasized',
+      'content' => 'js: markdownEditor.emphasis();',
+      'icon' => 'md-make-em.gif',
+      'accesskey' => '',
+      'weight' => '1',
+    ),
+    2 => 
+    array (
+      'title' => 'Make selected text strong',
+      'content' => 'js: markdownEditor.strongEmphasis();',
+      'icon' => 'md-make-strong.gif',
+      'accesskey' => '',
+      'weight' => '2',
+    ),
+    3 => 
+    array (
+      'title' => 'Format selected text as code',
+      'content' => 'js: markdownEditor.codeInline();',
+      'icon' => 'md-make-code.gif',
+      'accesskey' => '',
+      'weight' => '3',
+    ),
+    4 => 
+    array (
+      'title' => 'Format selected text as a code block',
+      'content' => 'js: markdownEditor.codeBlock();',
+      'icon' => 'md-make-code-block.gif',
+      'accesskey' => '',
+      'weight' => '4',
+    ),
+    5 => 
+    array (
+      'title' => 'Make selected text into a block quote',
+      'content' => 'js: markdownEditor.blockQuote();',
+      'icon' => 'md-make-quote.gif',
+      'accesskey' => '',
+      'weight' => '5',
+    ),
+    6 => 
+    array (
+      'title' => 'Make selected text into an ordered list (numbered)',
+      'content' => 'js: markdownEditor.orderedList();',
+      'icon' => 'md-make-ol.gif',
+      'accesskey' => '',
+      'weight' => '6',
+    ),
+    7 => 
+    array (
+      'title' => 'Make selected text into an unordered list (bullets)',
+      'content' => 'js: markdownEditor.unorderedList();',
+      'icon' => 'md-make-ul.gif',
+      'accesskey' => '',
+      'weight' => '7',
+    ),
+    8 => 
+    array (
+      'title' => 'Insert a definition list',
+      'content' => 'js:  new markdownEditor.DefinitionList();',
+      'icon' => 'md-add-dl.gif',
+      'accesskey' => '',
+      'weight' => '8',
+    ),
+    9 => 
+    array (
+      'title' => 'Insert a table',
+      'content' => 'js:  new markdownEditor.Table();',
+      'icon' => 'md-add-table.gif',
+      'accesskey' => '',
+      'weight' => '9',
+    ),
+    10 => 
+    array (
+      'title' => 'Insert an abbreviation (word or acronym with definition)',
+      'content' => 'js:  markdownEditor.abbreviation();',
+      'icon' => 'md-add-abbreviation.gif',
+      'accesskey' => '',
+      'weight' => '10',
+    ),
+    11 => 
+    array (
+      'title' => 'Insert a footnote',
+      'content' => 'js:  markdownEditor.footnote();',
+      'icon' => 'md-add-footnote.gif',
+      'accesskey' => '',
+      'weight' => '11',
+    ),
+    12 => 
+    array (
+      'title' => 'Make text into an autolink (turns URLs in links, turns words into section identifiers for navigating the document)',
+      'content' => 'js:  markdownEditor.autoLink();',
+      'icon' => 'md-add-autolink.gif',
+      'accesskey' => '',
+      'weight' => '12',
+    ),
+    13 => 
+    array (
+      'title' => 'Make text into a link (turns text into a link with more options)',
+      'content' => 'js:  markdownEditor.link();',
+      'icon' => 'md-make-link.gif',
+      'accesskey' => '',
+      'weight' => '13',
+    ),
+    14 => 
+    array (
+      'title' => 'Insert an image',
+      'content' => 'js:  markdownEditor.image();',
+      'icon' => 'md-add-picture.gif',
+      'accesskey' => '',
+      'weight' => '14',
+    ),
+    15 => 
+    array (
+      'title' => 'Insert a line break',
+      'content' => 'js: markdownEditor.lineBreak();',
+      'icon' => 'md-add-line.gif',
+      'accesskey' => '',
+      'weight' => '15',
+    ),
+    16 => 
+    array (
+      'title' => 'Insert a horizontal ruler (horizontal line)',
+      'content' => 'js: markdownEditor.horizontalRuler();',
+      'icon' => 'md-add-hr.gif',
+      'accesskey' => '',
+      'weight' => '16',
+    ),
+    17 => 
+    array (
+      'title' => 'Preview',
+      'content' => 'js: E.prvAjax();',
+      'icon' => 'preview.png',
+      'accesskey' => '',
+      'weight' => '17',
+    ),
+    18 => 
+    array (
+      'title' => 'Help',
+      'content' => 'js: E.help(\'fadeIn\');',
+      'icon' => 'md-help.gif',
+      'accesskey' => '',
+      'weight' => '18',
+    ),
+  ),
+)
\ No newline at end of file
diff --git a/buttons.csv b/buttons.csv
deleted file mode 100644
index bf9886e..0000000
--- a/buttons.csv
+++ /dev/null
@@ -1,19 +0,0 @@
-"title", "content", "icon", "accesskey", "weight"
-"Make selected text into a header", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\'; return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); markdownEditor.header();\';", "md-make-header.gif", "", "-10"
-"Italics: Make selected text emphasized", "js: markdownEditor.emphasis();", "md-make-em.gif", "", "-9"
-"Make selected text strong", "js: markdownEditor.strongEmphasis();", "md-make-strong.gif", "", "-8"
-"Format selected text as code", "js: markdownEditor.codeInline();", "md-make-code.gif", "", "-7"
-"Format selected text as a code block", "js: markdownEditor.codeBlock();", "md-make-code-block.gif", "", "-6"
-"Make selected text into a block quote", "js: markdownEditor.blockQuote();", "md-make-quote.gif", "", "-5"
-"Make selected text into an ordered list (numbered)", "js: markdownEditor.orderedList();", "md-make-ol.gif", "", "-4"
-"Make selected text into an unordered list (bullets)", "js: markdownEditor.unorderedList();", "md-make-ul.gif", "", "-3"
-"Insert a definition list", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\'; return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); new markdownEditor.DefinitionList();\';", "md-add-dl.gif", "", "-2"
-"Insert a table", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\'; return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); new markdownEditor.Table();\';", "md-add-table.gif", "", "-1"
-"Insert an abbreviation (word or acronym with definition)", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\';  return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); markdownEditor.abbreviation();\';", "md-add-abbreviation.gif", "", "0"
-"Insert a footnote", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\';  return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); markdownEditor.footnote();\';", "md-add-footnote.gif", "", "1"
-"Make text into an autolink (turns URLs in links, turns words into section identifiers for navigating the document)", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\'; return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); markdownEditor.autoLink();\';", "md-add-autolink.gif", "", "2"
-"Make text into a link (turns text into a link with more options)", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\'; return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); markdownEditor.link();\';", "md-make-link.gif", "", "3"
-"Insert an image", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\'; return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); markdownEditor.image();\';", "md-add-picture.gif", "", "4"
-"Insert a line break", "js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.lineBreak();", "md-add-line.gif", "", "5"
-"Insert a horizontal ruler (horizontal line)", "js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.horizontalRuler();", "md-add-hr.gif", "", "6"
-"Help", "php: $help_url = url('admin/help/markdowneditor', array('query' => null, 'fragment' => null, 'absolute' => true)); $imce_url = function_exists(\'imce_menu\') && user_access(\'access imce\') ? url(\'imce/browse\') : \'\'; return \'js: markdownEditor.settings.helpPath = \"\' . $help_url . \'\"; markdownEditor.settings.cssPath = \"\' . (base_path() . drupal_get_path(\'module\', \'bueditor\') .\'/library/markdown/markdowneditor.css\') . \'\"; markdownEditor.settings.IMCEPath = \"\' . $imce_url . \'\"; markdownEditor.settings.addStyleSheet(); markdownEditor.help();\';", "md-help.gif", "", "7"
\ No newline at end of file
diff --git a/icons/preview.png b/icons/preview.png
new file mode 100644
index 0000000..2569dc5
Binary files /dev/null and b/icons/preview.png differ
diff --git a/library/markdown/markdowneditor-ie.css b/library/markdown/markdowneditor-ie.css
index 84f6703..3f73f75 100644
--- a/library/markdown/markdowneditor-ie.css
+++ b/library/markdown/markdowneditor-ie.css
@@ -1,6 +1,3 @@
-/*
- */
-
 /**
  * @file
  * A test suite for selected functionality from MarkdownEditor.
diff --git a/library/markdown/markdowneditor.css b/library/markdown/markdowneditor.css
index 047e83e..ba92fc1 100644
--- a/library/markdown/markdowneditor.css
+++ b/library/markdown/markdowneditor.css
@@ -1,6 +1,3 @@
-/*
- */
-
 /**
  * @file
  * A test suite for selected functionality from MarkdownEditor.
@@ -10,7 +7,7 @@
  */
 
 #editor-dialog {
-  background-color:white;
+  background-color: white;
 }
 
 #editor-dialog .cnt {
@@ -18,49 +15,49 @@
 
 #editor-dialog .cnt textarea,
 #editor-dialog .cnt select {
-  width:150px;
+  width: 150px;
 }
 
 #editor-dialog .cnt table input {
-  float:left;
+  float: left;
 }
 
 #editor-dialog .cnt .imce-button {
-  display:block;
-  width:50x;
-  float:left;
-  margin-left:5px;
+  display: block;
+  width: 50x;
+  float: left;
+  margin-left: 5px;
 }
 
 #editor-dialog .cnt form {
-  display:block;
-  max-height:460px;
-  overflow:auto;
+  display: block;
+  max-height: 460px;
+  overflow: auto;
 }
 
 #editor-dialog .cnt td {
-  vertical-align:top;
+  vertical-align: top;
 }
 
 #editor-dialog .cnt td label {
-  display:block;
-  margin-top:5px;
+  display: block;
+  margin-top: 5px;
 }
 
 #editor-dialog .cnt .td-element {
-  min-width:260px;
+  min-width: 260px;
 }
 
 #editor-dialog fieldset {
   border: 1px solid #B3D8EF;
-  background-color:transparent;
-  background-image:none;
+  background-color: transparent;
+  background-image: none;
   margin: 0 10px 0 0;
 }
 
 #editor-dialog table,
 #editor-dialog tbody {
-  margin:0;
+  margin: 0;
   overflow: auto;
 }
 
@@ -70,41 +67,34 @@
   padding-bottom: 10px;
 }
 
-/*******************************************************************************
- * BUTTONS
- ******************************************************************************/
-
+/* Buttons */
 .markdowneditor-dialog-help-button {
-  float:left;
-  width:30px;
+  float: left;
+  padding: 4px 15px;
 }
 
 .markdowneditor-dialog-cancel, .markdowneditor-dialog-submit {
-  width:60px;
+  padding: 4px 30px;
 }
 
 .markdowneditor-dialog-cancel {
-  float:right;
+  float: right;
 }
 
 .markdowneditor-dialog-submit {
-  float:right;
-  margin-right:5px;
+  float: right;
+  margin-right: 5px;
 }
 
-
-/*******************************************************************************
- * CLEARFIX
- ******************************************************************************/
-
+/* Clearfix */
 #editor-dialog .clearfix:after,
 #editor-dialog:after,
 #markdowneditor-dialog-definition-list .content-row:after,
 #markdowneditor-dialog-definition-list .header-row:after {
-  content: "."; 
-  display: block; 
-  height: 0; 
-  clear: both; 
+  content: ".";
+  display: block;
+  height: 0;
+  clear: both;
   visibility: hidden;
 }
 
@@ -115,14 +105,10 @@
   display: inline-block;
 }
 
-
-/*******************************************************************************
- * IMAGE & LINK
- ******************************************************************************/
-
+/* Image & Link */
 #markdowneditor-dialog-image .td-element input,
 #markdowneditor-dialog-link .td-element input {
-  width:250px;
+  width: 250px;
 }
 
 #markdowneditor-dialog-image .imce-button-wrapper,
@@ -138,163 +124,157 @@
 
 #markdowneditor-dialog-image tbody,
 #markdowneditor-dialog-link tbody {
-  display:block;
-  padding-bottom:10px;
+  display: block;
+  padding-bottom: 10px;
 }
 
 #markdowneditor-dialog-image #dialog_element_3,
 #markdowneditor-dialog-link #dialog_element_3 {
-  width:163px;
+  width: 163px;
 }
 
-
-/*******************************************************************************
- * DEFINITION LIST
- ******************************************************************************/
-
+/* Definition List */
 #markdowneditor-dialog-definition-list .modification input {
-  display:block;
-  clear:both;
-  width:30px;
-  margin-bottom:3px;
+  display: block;
+  clear: both;
+  width: 30px;
+  margin-bottom: 3px;
 }
 
 #markdowneditor-dialog-definition-list form {
-  min-width:380px;
-  padding:10px;
-  margin-bottom:10px;
+  min-width: 380px;
+  padding: 10px;
+  margin-bottom: 10px;
   width: 420px;
 }
 
+/*
 #markdowneditor-dialog-definition-list .content-container {
-/*  padding-bottom:10px;
-  margin-bottom:10px;*/
+  padding-bottom: 10px;
+  margin-bottom: 10px;
 }
+*/
 
 #markdowneditor-dialog-definition-list .content-row {
-  padding:5px;
-  background-color:#B3D8EF;
-  margin-top:10px;
+  padding: 5px;
+  background-color: #B3D8EF;
+  margin-top: 10px;
 }
 
 #markdowneditor-dialog-definition-list .content-row.first {
-  margin-top:0;
+  margin-top: 0;
 }
 
 #markdowneditor-dialog-definition-list .header-row {
-  margin-bottom:8px;
+  margin-bottom: 8px;
 }
 
 #markdowneditor-dialog-definition-list .header-cell {
-  width:175px;
-  float:left;
+  width: 175px;
+  float: left;
 }
 
 #markdowneditor-dialog-definition-list .content-row .title-cell {
-  float:left;
-  margin-right:3px;
+  float: left;
+  margin-right: 3px;
 }
 
 #markdowneditor-dialog-definition-list .content-row .description-cell {
-  float:left;
-  margin-left:3px;
-  margin-right:3px;
+  float: left;
+  margin-left: 3px;
+  margin-right: 3px;
 }
 
 #markdowneditor-dialog-definition-list .content-row .modification {
-  float:left;
+  float: left;
 }
 
 #markdowneditor-dialog-definition-list .content-row .description-cell textarea {
-  display:block;
-  height:65px;
+  display: block;
+  height: 65px;
 }
 
 #markdowneditor-dialog-definition-list .add-button {
-  display:block;
-  clear:right;
+  display: block;
+  clear: right;
 }
 
 #markdowneditor-dialog-definition-list .prepend-row-button {
-  visibility:hidden;
+  visibility: hidden;
 }
 
 #markdowneditor-dialog-definition-list .first .prepend-row-button {
-  visibility:visible;
+  visibility: visible;
 }
 
 #markdowneditor-dialog-definition-list .modification input {
-  display:block;
-  margin-left:3px;
-  width:30px;
+  display: block;
+  margin-left: 3px;
+  width: 30px;
 }
 
-
-/*******************************************************************************
- * TABLE
- ******************************************************************************/
-
+/* Table */
 #markdowneditor-dialog-table .header-row input {
   border: 2px solid #2388BF;
 }
 
 #markdowneditor-dialog-table button {
-  width:30px;
+  width: 30px;
 }
 
 #markdowneditor-dialog-table th {
-  font-weight:normal;
+  font-weight: normal;
 }
 
 #markdowneditor-dialog-table form {
-  max-width:600px;
-  padding:10px;
-  padding-bottom:none;
+  max-width: 600px;
+  padding: 10px;
+  padding-bottom: none;
 }
 
 #markdowneditor-dialog-table table {
-  display:block;
-  margin:0;
+  display: block;
+  margin: 0;
 }
 
 #markdowneditor-dialog-table tbody {
-  display:block;
+  display: block;
 }
 
 #markdowneditor-dialog-table th {
-  border:none;
+  border: none;
 }
 
 #markdowneditor-dialog-table .header-row td,
 #markdowneditor-dialog-table .content-row td {
-  background-color:#B3D8EF;
+  background-color: #B3D8EF;
   border-bottom:3px solid #EDF5FA;
 }
 
 
 #markdowneditor-dialog-table .header-row .remove-row-button {
-  visibility:hidden;
+  visibility: hidden;
 }
 
 #markdowneditor-dialog-table .row-modification-container {
-  width:75px;
+  width: 75px;
 }
 
 #markdowneditor-dialog-table .header-row .add-row-button,
 #markdowneditor-dialog-table .row-modification-container .add-row-button {
-  margin-left:5px;
+  margin-left: 5px;
 }
 
 #markdowneditor-dialog-table .column-modification-cell .prepend-column-button {
-  visibility:hidden;
+  visibility: hidden;
 }
 
 #markdowneditor-dialog-table .column-modification-cell.first .prepend-column-button {
-  visibility:visible;
+  visibility: visible;
 }
 
 #markdowneditor-dialog-table .column-modification-cell button {
-  margin-right:5px;
+  margin-right: 5px;
 }
 
 #markdowneditor-dialog-table .column-modification-cell input {
@@ -302,5 +282,5 @@
 }
 
 #markdowneditor-dialog-table .header-row input {
-  width:145px;
-}
\ No newline at end of file
+  width: 145px;
+}
diff --git a/library/markdown/markdowneditor.js b/library/markdown/markdowneditor.js
index cc7a2e6..7523aa1 100644
--- a/library/markdown/markdowneditor.js
+++ b/library/markdown/markdowneditor.js
@@ -1,4 +1,3 @@
-
 /**
  * @file
  * MarkdownEditor JS library for BUEditor.
@@ -136,9 +135,9 @@ Cactus.DOM.Array = (function () {
      */
     for (var i = 0; i < array.length; i++) {
       if (shouldRemove (element === array [i])) {
-	removed = i;
+        removed = i;
       } else {
-	newArray.push (array[i]);
+        newArray.push (array[i]);
       }
     }
     /*
@@ -147,7 +146,7 @@ Cactus.DOM.Array = (function () {
     if (array.length > newArray.length) {
       Array.empty (array);
       while (newArray.length) {
-	array.push (newArray.shift());
+        array.push (newArray.shift());
       }
     }
 
@@ -162,70 +161,70 @@ Cactus.DOM.Array = (function () {
  * class names for HTML Elements.
  */
 Cactus.DOM.ClassNames = (function () {
-    function ClassNames () {
-
-    } ClassNames.prototype = {
-	/**
-         * Adds a class to an object. But only if the class doesn't already
-         * exist on the object
-         *
-         * @param HTMLElement o
-         * @param string className
-         */
-	add : function (o, className) {
-            // Only add if the className isn't already added
-	    if (!this.has(o, className)) {
-		// If the className property is empty, we can simply overwrite
-		// it.
-		if (!o.className) {
-		    o.className = className;
-		    // if it isn't empty, we have to prepend a space so that
-		    // "a" and "b" becomes "a b".
-		} else {
-		    o.className += " " + className;
-		}
-	    }
-	},
-	/**
-         * Checks if a given className is as a className of o. It assumes that
-         * class names are separated by spaces and all other characters will be
-         * counted as part of class names.
-         *
-         * @param HTMLElement o
-         * @param string className
-         * @return boolean
-         */
-	has : function (o, className) {
-	    return RegExp("(?:^| )" + className + "(?: |$)").test (o.className);
-	},
-	/**
-         * Removes a class from o
-         *
-         * @param HTMLElement o
-         * @param string className
-         */
-	del : function (o, className) {
-	    /*
-             * Make sure the class exists, so we don't waste time doing
-             * what isn't necessary
-             */
-	    if (this.has (o, className)) {
-		var classNames = this.get (o);
-		Array.remove (classNames, className);
-		o.className = classNames.join(" ");
-	    }
-	},
-	/**
-         * Returns an array containing all classnames of an element
-         *
-         * @param HTMLElement o
-         * @return Array
-         */
-	get : function (o) {
-	    return o.className.split (/\s+/);
-	}
-    };
-    return new ClassNames();
+  function ClassNames () {
+
+  } ClassNames.prototype = {
+    /**
+     * Adds a class to an object. But only if the class doesn't already
+     * exist on the object
+     *
+     * @param HTMLElement o
+     * @param string className
+     */
+    add : function (o, className) {
+      // Only add if the className isn't already added
+      if (!this.has(o, className)) {
+        // If the className property is empty, we can simply overwrite
+        // it.
+        if (!o.className) {
+            o.className = className;
+            // if it isn't empty, we have to prepend a space so that
+            // "a" and "b" becomes "a b".
+        } else {
+            o.className += " " + className;
+        }
+      }
+    },
+    /**
+     * Checks if a given className is as a className of o. It assumes that
+     * class names are separated by spaces and all other characters will be
+     * counted as part of class names.
+     *
+     * @param HTMLElement o
+     * @param string className
+     * @return boolean
+     */
+    has : function (o, className) {
+        return RegExp("(?:^| )" + className + "(?: |$)").test (o.className);
+    },
+    /**
+     * Removes a class from o
+     *
+     * @param HTMLElement o
+     * @param string className
+     */
+    del : function (o, className) {
+      /*
+       * Make sure the class exists, so we don't waste time doing
+       * what isn't necessary
+       */
+      if (this.has (o, className)) {
+        var classNames = this.get (o);
+        Array.remove (classNames, className);
+        o.className = classNames.join(" ");
+      }
+    },
+    /**
+     * Returns an array containing all classnames of an element
+     *
+     * @param HTMLElement o
+     * @return Array
+     */
+    get : function (o) {
+      return o.className.split (/\s+/);
+    }
+  };
+  return new ClassNames();
 })();
 
 Cactus.DOM.tag = (function () {
@@ -248,7 +247,8 @@ Cactus.DOM.tag = (function () {
   function append (o, contents) {
     if (typeof (contents) === "string" || typeof contents === "number") {
       o.appendChild (document.createTextNode (contents));
-    } else if (isArrayLike (contents)) {
+    }
+    else if (isArrayLike (contents)) {
       if (o.tagName.toLowerCase() === "select") {
         for (var i = 0, option; i < contents.length; i++) {
           option = contents[i];
@@ -258,12 +258,14 @@ Cactus.DOM.tag = (function () {
             o.selectedIndex = i;
           }
         }
-      } else {
+      }
+      else {
         for (var j = 0; j < contents.length; j++) {
           append (o, contents[j]);
         }
       }
-    } else if (contents) {
+    }
+    else if (contents) {
       o.appendChild (contents);
     }
   }
@@ -290,7 +292,8 @@ Cactus.DOM.tag = (function () {
     if (attributes.name && isIE) {
       o = document.createElement ("<" + name + ' name="' + attributes.name + '">');
       delete attributes.name;
-    } else {
+    }
+    else {
       o = document.createElement (name);
     }
 
@@ -316,7 +319,8 @@ Cactus.DOM.tag = (function () {
       // append to a select.
       if (q === "selected") {
         o._selected = attributes.selected;
-      } else {
+      }
+      else {
         o [q] = attributes [q];
       }
     }
@@ -780,7 +784,7 @@ markdownEditor.dialog = {
           element.label = [element.label, tag("span", { style : { color : "red" } }, "*")];
           element.attributes.className = "mandatory";
         }
-				
+
         // Create the label element.
         var label = tag("label", { htmlFor : element.attributes.id }, element.label);
 
@@ -1027,27 +1031,27 @@ markdownEditor.dialog = {
    * @param {Object} win
    */
   imceWindowLoad : function (win) {
-		win.imce.setSendTo(markdownEditor.t('Send to @app', {'@app': 'BUEditor'}), markdownEditor.dialog.imceWindowFinish);
+    win.imce.setSendTo(markdownEditor.t('Send to @app', {'@app': 'BUEditor'}), markdownEditor.dialog.imceWindowFinish);
     // TODO: Do not use jQuery here:
-		$(window).unload(function() {
+    $(window).unload(function() {
       if (MDEImceWindow && !MDEImceWindow.closed) MDEImceWindow.close();
     });
   },
-	
-	/**
-	 * Fill BUE dialog fields and close IMCE window
-	 * @param {Object} file
-	 * @param {Object} win
-	 */
-	imceWindowFinish : function (file, win) {
-	  var el = document.forms['markdowneditor-dialog-form'].elements;
-	  var val = {'text' : file.name, 'title' : file.name, 'href' : file.url}
-	  for (var i in val) {
-	    if (!el[i].value) el[i].value = val[i];
-	  }
-	  win.blur();//or close()
-	  el[el.length-1].focus();//focus on last element.
-	},
+
+  /**
+   * Fill BUE dialog fields and close IMCE window
+   * @param {Object} file
+   * @param {Object} win
+   */
+  imceWindowFinish : function (file, win) {
+    var el = document.forms['markdowneditor-dialog-form'].elements;
+    var val = {'text' : file.name, 'title' : file.name, 'href' : file.url}
+    for (var i in val) {
+      if (!el[i].value) el[i].value = val[i];
+    }
+    win.blur();//or close()
+    el[el.length-1].focus();//focus on last element.
+  },
 
   /**
    * Gives focus to the first form element in the dialog.
@@ -2240,7 +2244,7 @@ markdownEditor.strongEmphasis = function () {
   }
   // Otherwise asterisks are added around the selection.
   else {
-		markdownEditor.selection.replace(/^\**([\s\S]+?)\**$/, "**$1**");
+    markdownEditor.selection.replace(/^\**([\s\S]+?)\**$/, "**$1**");
   }
 };
 
@@ -3770,5 +3774,3 @@ markdownEditor.references = (function () {
 
   return new References();
 })();
-
-
diff --git a/markdowneditor.buttons.inc b/markdowneditor.buttons.inc
index 7b9ebed..275fd7a 100644
--- a/markdowneditor.buttons.inc
+++ b/markdowneditor.buttons.inc
@@ -1,4 +1,10 @@
 <?php
+/**
+ * @file
+ * Buttons for the markdowneditor module.
+ *
+ */
+
 /*
  * Markdown Editor
  * by Jakob Persson of NodeOne <jakob@nodeone.se>
@@ -9,10 +15,7 @@
  *   NodeOne - www.nodeone.se
  */
 
-$help_url = url('admin/help/markdowneditor');
-$imce_url = ( module_exists('imce') ? url('imce/browse') : null );
-
-$js_helpPath = "markdownEditor.settings.helpPath = '$help_url';";
+$imce_url = module_exists('imce') ? url('imce/browse') : NULL;
 $js_imceURL = ( $imce_url ? "markdownEditor.settings.IMCEPath = '$imce_url';" : '' );
 
 // Define buttons
@@ -30,165 +33,176 @@ $mde_buttons = array();
 $i = 0;
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Make selected text into a header"),
-  "js: $js_helpPath $js_imceURL markdownEditor.header();",
+  $eid,
+  t("Make selected text into a header"),
+  "js: $js_imceURL markdownEditor.header();",
   "md-make-header.gif",
-  "",
--10
+  "H",
+  -10,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Italics: Make selected text emphasized"),
+  $eid,
+  t("Italics: Make selected text emphasized"),
   "js: markdownEditor.emphasis();",
   "md-make-em.gif",
-  "",
--9
+  "I",
+  -9,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Make selected text strong"),
+  $eid,
+  t("Make selected text strong"),
   "js: markdownEditor.strongEmphasis();",
   "md-make-strong.gif",
-  "",
--8
+  "B",
+  -8,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Format selected text as code"),
+  $eid,
+  t("Format selected text as code"),
   "js: markdownEditor.codeInline();",
   "md-make-code.gif",
   "",
--7
+  -7,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Format selected text as a code block"),
+  $eid,
+  t("Format selected text as a code block"),
   "js: markdownEditor.codeBlock();",
   "md-make-code-block.gif",
   "",
--6
+  -6,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Make selected text into a block quote"),
-    "js: markdownEditor.blockQuote();",
-    "md-make-quote.gif",
-    "",
--5
+  $eid,
+  t("Make selected text into a block quote"),
+  "js: markdownEditor.blockQuote();",
+  "md-make-quote.gif",
+  "Q",
+  -5,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Make selected text into an ordered list (numbered)"),
-    "js: markdownEditor.orderedList();",
-    "md-make-ol.gif",
-    "",
--4
+  $eid,
+  t("Make selected text into an ordered list (numbered)"),
+  "js: markdownEditor.orderedList();",
+  "md-make-ol.gif",
+  "O",
+  -4,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Make selected text into an unordered list (bullets)"),
-    "js: markdownEditor.unorderedList();",
-    "md-make-ul.gif",
-    "",
--3
+  $eid,
+  t("Make selected text into an unordered list (bullets)"),
+  "js: markdownEditor.unorderedList();",
+  "md-make-ul.gif",
+  "N",
+  -3,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Insert a definition list"),
-    "js: $js_helpPath $js_imceURL new markdownEditor.DefinitionList();",
-    "md-add-dl.gif",
-    "",
--2
+  $eid,
+  t("Insert a definition list"),
+  "js: $js_imceURL new markdownEditor.DefinitionList();",
+  "md-add-dl.gif",
+  "",
+  -2,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Insert a table"),
-    "js: $js_helpPath $js_imceURL new markdownEditor.Table();",
-    "md-add-table.gif",
-    "",
--1
+  $eid,
+  t("Insert a table"),
+  "js: $js_imceURL new markdownEditor.Table();",
+  "md-add-table.gif",
+  "T",
+  -1,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-("Insert an abbreviation (word or acronym with definition)"),
-    "js: $js_helpPath $js_imceURL markdownEditor.abbreviation();",
-    "md-add-abbreviation.gif",
-    "",
-0
+  $eid,
+  ("Insert an abbreviation (word or acronym with definition)"),
+  "js: $js_imceURL markdownEditor.abbreviation();",
+  "md-add-abbreviation.gif",
+  "",
+  0,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Insert a footnote"),
-    "js: $js_helpPath $js_imceURL markdownEditor.footnote();",
-    "md-add-footnote.gif",
-    "",
-1
+  $eid,
+  t("Insert a footnote"),
+  "js: $js_imceURL markdownEditor.footnote();",
+  "md-add-footnote.gif",
+  "F",
+  1,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Make text into an autolink (turns URLs in links, turns words into section identifiers for navigating the document)"),
-    "js: $js_helpPath $js_imceURL markdownEditor.autoLink();",
-    "md-add-autolink.gif",
-    "",
-2
+  $eid,
+  t("Make text into an autolink (turns URLs in links, turns words into section identifiers for navigating the document)"),
+  "js: $js_imceURL markdownEditor.autoLink();",
+  "md-add-autolink.gif",
+  "A",
+  2,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Make text into a link (turns text into a link with more options)"),
-    "js: $js_helpPath $js_imceURL markdownEditor.link();",
-    "md-make-link.gif",
-    "",
-3
+  $eid,
+  t("Make text into a link (turns text into a link with more options)"),
+  "js: $js_imceURL markdownEditor.link();",
+  "md-make-link.gif",
+  "L",
+  3,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Insert an image"),
-    "js: $js_helpPath $js_imceURL markdownEditor.image();",
-    "md-add-picture.gif",
-    "",
-4
+  $eid,
+  t("Insert an image"),
+  "js: $js_imceURL markdownEditor.image();",
+  "md-add-picture.gif",
+  "M",
+  4,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Insert a line break"),
-    "js: $js_helpPath markdownEditor.lineBreak();",
-    "md-add-line.gif",
-    "",
-5
+  $eid,
+  t("Insert a line break"),
+  "js: markdownEditor.lineBreak();",
+  "md-add-line.gif",
+  "R",
+  5,
 );
 
 $mde_buttons[$i++] = array(
-$eid,
-t("Insert a horizontal ruler (horizontal line)"),
-    "js: $js_helpPath markdownEditor.horizontalRuler();",
-    "md-add-hr.gif",
-    "",
-6
+  $eid,
+  t("Insert a horizontal ruler (horizontal line)"),
+  "js: markdownEditor.horizontalRuler();",
+  "md-add-hr.gif",
+  "",
+  6,
 );
 
+if (module_exists('ajax_markup')) {
+  $mde_buttons[$i++] = array(
+    $eid,
+    t("Preview"),
+    "js: E.prvAjax();",
+    "preview.png",
+    "P",
+    7,
+  );
+}
+
 $mde_buttons[$i++] = array(
-$eid,
-t("Help"),
-    "js: $js_helpPath $js_imceURL markdownEditor.help();",
-    "md-help.gif",
-    "",
-7
+  $eid,
+  t("Help"),
+  "js: E.help('fadeIn');",
+  "md-help.gif",
+  "",
+  8,
 );
 
-// EoF
\ No newline at end of file
+// EoF
diff --git a/markdowneditor.info b/markdowneditor.info
index 7c3b151..49fb960 100644
--- a/markdowneditor.info
+++ b/markdowneditor.info
@@ -1,5 +1,5 @@
-name = "Markdown Editor for BUEditor"
-description = "Provides a toolbar for writing Markdown syntax with BUEditor."
-package = Other
-core = 6.x
+name = Markdown Editor for BUEditor
+description = Provides a toolbar for writing Markdown syntax with BUEditor.
+core = 7.x
+package = Content authoring
 dependencies[] = bueditor
diff --git a/markdowneditor.install b/markdowneditor.install
index 9d3bea2..8c83214 100644
--- a/markdowneditor.install
+++ b/markdowneditor.install
@@ -1,4 +1,10 @@
 <?php
+/**
+ * @file
+ * Install, update and uninstall functions for the markdowneditor module.
+ *
+ */
+
 /*
  * Markdown Editor
  * by Jakob Persson of NodeOne <jakob@nodeone.se>
@@ -10,38 +16,41 @@
  */
 
 /**
- * Implementation of hook_install()
+ * Implements hook_install().
  */
 function markdowneditor_install() {
   if (_markdowneditor_insert_latest()) {
-    drupal_set_message(t("Markdown Editor for BUEditor successfully installed. Go to !buesettings to set up 'Role-editor assignments' to select the roles that may use it.", array('!buesettings' => l('Administer > Site configuration > BUEditor', "admin/settings/bueditor"))));
+    $t = get_t();
+    drupal_set_message($t('Markdown Editor for BUEditor successfully installed. Go to !buesettings to set up "Role-editor assignments" to select the roles that may use it.', array('!buesettings' => l('Administration > Configuration > BUEditor', 'admin/config/content/bueditor'))));
   }
 }
 
 /**
- * Implementation of hook_uninstall()
+ * Implements hook_uninstall().
  */
 function markdowneditor_uninstall() {
-
-  $eid = variable_get('markdowneditor_eid', false);
+  $eid = variable_get('markdowneditor_eid', FALSE);
 
   if ($eid) {
-    $sql_buttons = "DELETE FROM {bueditor_buttons} WHERE eid = %d";
-    $sql_editor = "DELETE FROM {bueditor_editors} WHERE eid = %d";
-    db_query($sql_buttons, $eid);
-    db_query($sql_editor, $eid);
+    db_delete('bueditor_buttons')
+      ->condition('eid', $eid)
+      ->execute();
+    db_delete('bueditor_editors')
+      ->condition('eid', $eid)
+      ->execute();
   }
 
   // Empty site cache
-  cache_clear_all('*', 'cache', true);
-  cache_clear_all('*', 'cache_filter', true);
-  cache_clear_all('*', 'cache_menu', true);
-  cache_clear_all('*', 'cache_page', true);
+  cache_clear_all('*', 'cache', TRUE);
+  cache_clear_all('*', 'cache_filter', TRUE);
+  cache_clear_all('*', 'cache_menu', TRUE);
+  cache_clear_all('*', 'cache_page', TRUE);
 
   // Clear variables
-  db_query("DELETE FROM {variable} WHERE name LIKE('%s%%') ", 'markdowneditor_');
+  db_delete('variable')
+    ->condition('name', 'markdowneditor_%', 'LIKE')
+    ->execute();
   cache_clear_all('variables', 'cache');
-
 }
 
 /**
@@ -50,21 +59,25 @@ function markdowneditor_uninstall() {
 function _markdowneditor_insert_latest($name = 'default') {
 
   // Set up variables
-  $name = 'markdowneditor';
+  $name = 'Markdowneditor';
   $path = drupal_get_path('module', 'markdowneditor');
 
   // Set up library paths
-  $library_paths = "$path/library/markdown/markdowneditor.js\n$path/library/markdown/markdowneditor.css\n%BUEDITOR/library/bue.popup.js\n%BUEDITOR/library/bue.popup.css";
+  $library_paths = "$path/library/markdown/markdowneditor.js\n$path/library/markdown/markdowneditor.css\n%BUEDITOR/library/bue.min.default.js\n%BUEDITOR/library/bue.popup.css";
 
   // Add editor
-  $sql = "INSERT INTO {bueditor_editors} (name, pages, excludes, iconpath, librarypath) VALUES ('%s', '%s', '%s', '%s', '%s')";
-  db_query($sql, $name, "node/*\ncomment/*", 'edit-log', "$path/icons", $library_paths);
-
-  // Get editor's eid
-  $eid = db_last_insert_id('bueditor_editors', 'eid');
+  $eid = db_insert('bueditor_editors')
+    ->fields(array(
+      'name' => $name,
+      'pages' => "node/*\ncomment/*",
+      'excludes' => 'edit-log',
+      'iconpath' => $path . '/icons',
+      'librarypath' => $library_paths,
+    ))
+    ->execute();
 
   // Include default button definitions
-  require_once("$path/markdowneditor.buttons.inc");
+  require_once DRUPAL_ROOT . '/' . $path . '/markdowneditor.buttons.inc';
 
   // We store a local copy of the bids so we can update them later as we
   // then know the button ids (bid)
@@ -72,10 +85,17 @@ function _markdowneditor_insert_latest($name = 'default') {
 
   // Add buttons
   foreach ($mde_buttons as $mde_bkey => $button) {
-
     // Insert the button
-    db_query("INSERT INTO {bueditor_buttons} (eid, title, content, icon, accesskey, weight) VALUES (%d, '%s', '%s', '%s', '%s', %d)", $button);
-    $bid = db_last_insert_id('bueditor_buttons', 'bid');
+    $bid = db_insert('bueditor_buttons')
+      ->fields(array(
+          'eid' => $button['0'],
+          'title' => $button['1'],
+          'content' => $button['2'],
+          'icon' => $button['3'],
+          'accesskey' => $button['4'],
+          'weight' => $button['5'],
+        ))
+      ->execute();
 
     // Reference bid with MDE button array key so we can update our buttons later if need be
     $buttons[$mde_bkey] = $bid;
@@ -91,7 +111,5 @@ function _markdowneditor_insert_latest($name = 'default') {
   $fprint = md5($js_helpPath . $js_imceURL);
   variable_set('markdowneditor_content_fprint', $fprint);
 
-
   return $eid;
-
-}
\ No newline at end of file
+}
diff --git a/markdowneditor.module b/markdowneditor.module
index 85d486e..c033f2e 100644
--- a/markdowneditor.module
+++ b/markdowneditor.module
@@ -10,7 +10,7 @@
  */
 
 /**
- * Implementation of hook_form_alter()
+ * Implements hook_form_alter().
  */
 function markdowneditor_form_system_modules_alter(&$form, &$form_state) {
   $form['#submit'][] = '_markdowneditor_form_system_modules_submit';
@@ -31,26 +31,30 @@ function _markdowneditor_update_buttons() {
   $path = drupal_get_path('module', 'markdowneditor');
 
   // Load buttons
-  $buttons = variable_get('markdowneditor_buttons', false);
+  $buttons = variable_get('markdowneditor_buttons', FALSE);
 
   // Include default button definitions
-  require_once("$path/markdowneditor.buttons.inc");
+  require_once DRUPAL_ROOT . '/' . $path . '/markdowneditor.buttons.inc';
 
   if ($buttons && !empty($mde_buttons)) {
-
     // Calculate table content fingerprint and compare to stored copy
     // only update table if contents have changed
     $fprint = md5($js_helpPath . $js_imceURL);
 
-    if ($fprint != variable_get('markdowneditor_content_fprint', null)) {
+    if ($fprint != variable_get('markdowneditor_content_fprint', NULL)) {
 
       // Store new fingerprint
       variable_set('markdowneditor_content_fprint', $fprint);
 
       // Update buttons
       foreach ($buttons as $mde_bkey => $bid) {
-        db_query("UPDATE {bueditor_buttons} SET content = '%s' WHERE bid = %d", $mde_buttons[$mde_bkey][2], $bid);
+        db_update('bueditor_buttons')
+          ->fields(array(
+            'content' => $mde_buttons[$mde_bkey][2],
+          ))
+          ->condition('bid', $bid)
+          ->execute();
       }
     }
   }
-}
\ No newline at end of file
+}
