diff --git a/modules/modalframe_example/modalframe_example.info b/modules/modalframe_example/modalframe_example.info
index a70b5be..8ab801a 100644
--- a/modules/modalframe_example/modalframe_example.info
+++ b/modules/modalframe_example/modalframe_example.info
@@ -2,4 +2,4 @@ name = Modal Frame Example
 description = Example for the Modal Frame API.
 package = Modal frame
 dependencies[] = modalframe
-core = 6.x
+core = 7.x
diff --git a/modules/modalframe_example/modalframe_example.js b/modules/modalframe_example/modalframe_example.js
index e0ea740..d822b44 100644
--- a/modules/modalframe_example/modalframe_example.js
+++ b/modules/modalframe_example/modalframe_example.js
@@ -1,49 +1,51 @@
 
 (function ($) {
 
-Drupal.behaviors.modalFrameExample = function() {
-  $('.modalframe-example-child:not(.modalframe-example-processed)').addClass('modalframe-example-processed').click(function() {
-    var element = this;
-
-    // This is our onSubmit callback that will be called from the child window
-    // when it is requested by a call to modalframe_close_dialog() performed
-    // from server-side submit handlers.
-    function onSubmitCallbackExample(args, statusMessages) {
-      // Display status messages generated during submit processing.
-      if (statusMessages) {
-        $('.modalframe-example-messages').hide().html(statusMessages).show('slow');
+Drupal.behaviors.modalFrameExample = {
+  attach: function() {
+    $('.modalframe-example-child:not(.modalframe-example-processed)').addClass('modalframe-example-processed').click(function() {
+      var element = this;
+  
+      // This is our onSubmit callback that will be called from the child window
+      // when it is requested by a call to modalframe_close_dialog() performed
+      // from server-side submit handlers.
+      function onSubmitCallbackExample(args, statusMessages) {
+        // Display status messages generated during submit processing.
+        if (statusMessages) {
+          $('.modalframe-example-messages').hide().html(statusMessages).show('slow');
+        }
+  
+        if (args && args.message) {
+          // Provide a simple feedback alert deferred a little.
+          setTimeout(function() { alert(args.message); }, 500);
+        }
       }
-
-      if (args && args.message) {
-        // Provide a simple feedback alert deferred a little.
-        setTimeout(function() { alert(args.message); }, 500);
+  
+      // Hide the messages are before opening a new dialog.
+      $('.modalframe-example-messages').hide('fast');
+  
+      // Build modal frame options.
+      var modalOptions = {
+        url: $(element).attr('href'),
+        autoFit: true,
+        onSubmit: onSubmitCallbackExample
+      };
+  
+      // Try to obtain the dialog size from the className of the element.
+      var regExp = /^.*modalframe-example-size\[\s*([0-9]*\s*,\s*[0-9]*)\s*\].*$/;
+      if (typeof element.className == 'string' && regExp.test(element.className)) {
+        var size = element.className.replace(regExp, '$1').split(',');
+        modalOptions.width = parseInt(size[0].replace(/ /g, ''));
+        modalOptions.height = parseInt(size[1].replace(/ /g, ''));
       }
-    }
-
-    // Hide the messages are before opening a new dialog.
-    $('.modalframe-example-messages').hide('fast');
-
-    // Build modal frame options.
-    var modalOptions = {
-      url: $(element).attr('href'),
-      autoFit: true,
-      onSubmit: onSubmitCallbackExample
-    };
-
-    // Try to obtain the dialog size from the className of the element.
-    var regExp = /^.*modalframe-example-size\[\s*([0-9]*\s*,\s*[0-9]*)\s*\].*$/;
-    if (typeof element.className == 'string' && regExp.test(element.className)) {
-      var size = element.className.replace(regExp, '$1').split(',');
-      modalOptions.width = parseInt(size[0].replace(/ /g, ''));
-      modalOptions.height = parseInt(size[1].replace(/ /g, ''));
-    }
-
-    // Open the modal frame dialog.
-    Drupal.modalFrame.open(modalOptions);
-
-    // Prevent default action of the link click event.
-    return false;
-  });
+  
+      // Open the modal frame dialog.
+      Drupal.modalFrame.open(modalOptions);
+  
+      // Prevent default action of the link click event.
+      return false;
+    });
+  }
 };
 
 })(jQuery);
diff --git a/modules/modalframe_example/modalframe_example.module b/modules/modalframe_example/modalframe_example.module
index 4fe2fd4..c7c7ee0 100644
--- a/modules/modalframe_example/modalframe_example.module
+++ b/modules/modalframe_example/modalframe_example.module
@@ -8,8 +8,14 @@
 /**
  * Implementation of hook_perm().
  */
-function modalframe_example_perm() {
-  return array('access modalframe examples');
+function modalframe_example_permission() {
+  $permissions = array(
+    'access modalframe examples' => array(
+      'title' => t('access modalframe examples'),
+    	'description' => t('Collection of examples using modalframe.')
+    )
+  );
+  return $permissions;
 }
 
 /**
@@ -22,7 +28,7 @@ function modalframe_example_menu() {
     'title' => 'Modal Frame Examples',
     'page callback' => 'modalframe_example_page',
     'access arguments' => array('access modalframe examples'),
-    'type' => MENU_NORMAL_ITEM,
+  	'type' => MENU_NORMAL_ITEM,
   );
 
   // Hello world example.
@@ -77,8 +83,7 @@ function modalframe_example_page() {
     modalframe_example_get_item(t('Simple form where menu callback is a custom function'), 'modalframe-example/simple-page/first/second/third', '350,400'),
     modalframe_example_get_item(t('Custom menu callback to edit a node'), 'modalframe-example/node-edit'),
   );
-  $output .= theme('item_list', $items);
-
+  $output .= theme('item_list', array('items' => $items));
   return $output;
 }
 
@@ -112,8 +117,8 @@ function modalframe_example_simple_page($first = NULL, $second = NULL, $third =
 /**
  * Generate the form for the child window.
  */
-function modalframe_example_simple_form(&$form_state) {
-  $form = array();
+function modalframe_example_simple_form($form, &$form_state) {
+	$form = array();
 
   // Send the Modal Frame javascript for child windows to the page.
   modalframe_child_js();
@@ -162,8 +167,11 @@ function modalframe_example_node_edit_page() {
   modalframe_child_js();
 
   // Let's find the last created node the current user has edit access to.
-  $nid = (int)db_result(db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n ORDER BY n.nid DESC'), 0, 1));
+//   $nid = (int)db_result(db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n ORDER BY n.nid DESC'), 0, 1));
+  $nid = db_query('SELECT n.nid FROM {node} n ORDER BY n.nid DESC')->fetchField();
+
   $node = node_load($nid);
+  
   if (!$node || !node_access('update', $node)) {
     drupal_set_message(t('Sorry, could not find any node that you are allowed to edit for this test.'), 'error');
     drupal_not_found();
@@ -179,7 +187,8 @@ function modalframe_example_node_edit_page() {
 
   // Render the node edit form itself.
   module_load_include('inc', 'node', 'node.pages');
-  $output .= node_page_edit($node);
+  $node_edit_form = node_page_edit($node);
+  $output .= drupal_render($node_edit_form);
 
   return $output;
 }
@@ -208,15 +217,17 @@ function modalframe_example_form_alter(&$form, $form_state, $form_id) {
       // where we may wish to close the modal frame dialog.
       // So let's keep this as simple as possible. We are now hidding all
       // buttons, except "Save" and "Preview".
-      foreach (element_children($form['buttons']) as $key) {
-        if (!in_array($key, array('submit', 'preview')) && isset($form['buttons'][$key]) && $form['buttons'][$key]) {
-          unset($form['buttons'][$key]);
+      foreach (element_children($form['actions']) as $key) {
+        if (!in_array($key, array('submit', 'preview')) && isset($form['actions'][$key]) && $form['actions'][$key]) {
+          unset($form['actions'][$key]);
+        }
+        if ($key == 'submit') {
+          // Append our submit handler. This is required if we want a chance to
+          // close the modal frame dialog. Submit handler must be attached 
+          // directly to submit button to work with node edit field. 
+          $form['actions'][$key]['#submit'][] = 'modalframe_example_form_submit';
         }
       }
-
-      // Append our submit handler. This is required if we want a chance to
-      // close the modal frame dialog.
-      $form['#submit'][] = 'modalframe_example_form_submit';
     }
   }
 }
@@ -231,7 +242,10 @@ function modalframe_example_form_alter(&$form, $form_state, $form_id) {
  */
 function modalframe_example_form_submit($form, &$form_state) {
   // Ignore preview requests. Close dialog only when user clicks "Save" button.
-  if ($form_state['values']['op'] == t('Save')) {
+  if ($form_state['triggering_element']['#value'] == t('Save')) {
+    // Disable form redirection. Required to ensure modelframe_close_dialog
+    // will function correctly with node edit form.
+    $form_state['redirect'] = FALSE;  
     // Tell the parent window to close the modal frame dialog.
     modalframe_close_dialog(array(
       'message' => t('This is an argument sent by the Modal Frame API from the submit handler attached to the node edit form!'),
