diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js
index 2384920..a0668c6 100644
--- a/core/misc/machine-name.js
+++ b/core/misc/machine-name.js
@@ -31,15 +31,21 @@ Drupal.behaviors.machineName = {
     var $context = $(context);
     var source_id, options, machine;
 
-    function clickEditHandler() {
-      $wrapper.show();
+    function clickEditHandler(e) {
+      options = e.data;
+      var $target = $context.find(options.target);
+      $target.closest('.form-item').show();
       $target.focus();
-      $suffix.hide();
-      $source.unbind('.machineName');
+      $context.find(options.suffix).hide();
+      $context.find(options.source_id).unbind('.machineName');
       return false;
     }
 
     function machineNameHandler(e) {
+      options = e.data;
+      var $target = $context.find(options.target);
+      var $suffix = $context.find(options.suffix);
+      var $preview = $suffix.find('.machine-name-value');
       machine = self.transliterate($(e.target).val(), options);
       // Set the machine name to the transliterated value.
       if (machine !== '') {
@@ -59,6 +65,7 @@ Drupal.behaviors.machineName = {
     for (source_id in settings.machineName) {
       if (settings.machineName.hasOwnProperty(source_id)) {
         options =  settings.machineName[source_id];
+        options.source_id = source_id;
 
         var $source = $context.find(source_id).addClass('machine-name-source');
         var $target = $context.find(options.target).addClass('machine-name-target');
@@ -99,14 +106,14 @@ Drupal.behaviors.machineName = {
         }
 
         // If it is editable, append an edit link.
-        var $link = $('<span class="admin-link"><a href="#">' + Drupal.t('Edit') + '</a></span>').click(clickEditHandler);
+        var $link = $('<span class="admin-link"><a href="#">' + Drupal.t('Edit') + '</a></span>').click(options, clickEditHandler);
         $suffix.append(' ').append($link);
 
         // Preview the machine name in realtime when the human-readable name
         // changes, but only if there is no machine name yet; i.e., only upon
         // initial creation, not when editing.
         if ($target.val() === '') {
-          $source.bind('keyup.machineName change.machineName', machineNameHandler)
+          $source.bind('keyup.machineName change.machineName', options, machineNameHandler)
           // Initialize machine name preview.
           .keyup();
         }
