=== added file 'form_update.txt'
--- /dev/null	
+++ form_update.txt	
@@ -0,0 +1,70 @@
+If you had a page which only contained a form:
+
+<?php
+function mymodule_page_form() {
+  // form definition here
+  // ...
+  return drupal_get_form('mymodule_page_form', $form);
+}
+?>
+
+then just change it to:
+
+<?php
+function mymodule_page_form() {
+  // form definition here
+  // ...
+  return $form;
+}
+?>
+
+If you used another form_id or a callback (which is now called function_prefix):
+
+<?php
+function mymodule_page_form() {
+  // form definition here
+  // ...
+  return drupal_get_form('myform_id', $form, 'mycallback');
+}
+?>
+
+that becomes:
+
+<?php
+function mymodule_page_form() {
+  // form definition here
+  // ...
+  $form['#form_id'] = 'myform_id';
+  $form['#function_prefix'] = 'mycallback';
+  return $form;
+}
+?>
+
+Finally, if you had a page which contained a form and other things, then you need to move the form to a separate function:
+
+<?php
+function mymodule_page_form() {
+  // form definition here
+  // ...
+  $output = drupal_get_form('myform_id', $form);
+  // ...
+}
+?>
+
+then you will need:
+
+<?php
+function mymodule_foo() {
+  // form definition here
+  // ...
+  $form['#form_id'] = 'myform_id';
+  return $form;
+}
+function mymodule_page_form() {
+  $output = drupal_get_form('mymodule_foo');
+  // ...
+}
+?>
+
+Finally, system_settings_form now just needs an array, remove the 
+form_id.
=== modified file 'includes/form.inc'
--- includes/form.inc	
+++ includes/form.inc	
@@ -20,20 +20,41 @@
  * will attempt to validate it, using drupal_validate_form(),
  * and then submit the form using drupal_submit_form().
  *
- * @param $form_id
- *   A unique string identifying the form. Allows each form to be
- *   themed. Pass NULL to suppress the form_id parameter (produces
- *   a shorter URL with method=get)
- * @param $form
- *   An associative array containing the structure of the form.
- * @param $callback
- *   An optional callback that will be used in addition to the form_id.
- *
+ * @param $form_handler
+ *   A unique string identifying the form in the array returned from
+ *   hook_forms.
+ * @param ...
+ *   Any number of arguments passed to the form handler.
  */
-function drupal_get_form($form_id, &$form, $callback = NULL) {
+function drupal_get_form($form_handler) {
+  static $forms;
+
+  $args = func_get_args();
+  $form_handler = array_shift($args);
+  if (!function_exists($form_handler)) {
+    if (!isset($forms)) {
+      $forms = module_invoke_all('forms');
+    }
+    $form_definition = $forms[$form_handler];
+    if (isset($form_definition['callback arguments'])) {
+      $args = array_merge($form_definition['callback arguments'], $args);
+    }
+    if (isset($form_definition['callback'])) {
+      $callback = $form_definition['callback'];
+    }
+  }
+  $form = call_user_func_array(isset($callback) ? $callback : $form_handler, $args);
+  return drupal_process_form($form_handler, $form);
+}
+
+function drupal_process_form($form_handler, $form) {
   global $form_values, $form_submitted, $user, $form_button_counter;
   static $saved_globals = array();
 
+  $form_id = isset($form['#form_id']) ? $form['#form_id'] : $form_handler;
+  if (isset($form['#function_prefix'])) {
+    $function_prefix = $form['#function_prefix'];
+  }
   // Save globals in case of indirect recursive call
   array_push($saved_globals, array($form_values, $form_submitted, $form_button_counter));
 
@@ -41,20 +62,20 @@ function drupal_get_form($form_id, &$for
   $form_submitted = FALSE;
   $form_button_counter = array(0, 0);
 
-  $form = drupal_build_form($form_id, $form, $callback);
+  $form = drupal_build_form($form_id, $form, $function_prefix);
 
-  if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) {
-    drupal_validate_form($form_id, $form, $callback);
+  if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $function_prefix))) {
+    drupal_validate_form($form_id, $form);
     // IE does not send a button value when there is only one submit button (and no non-submit buttons)
     // and you submit by pressing enter.
     // In that case we accept a submission without button values.
     if (($form_submitted || (!$form_button_counter[0] && $form_button_counter[1])) && !form_get_errors()) {
-      $redirect = drupal_submit_form($form_id, $form, $callback);
+      $redirect = drupal_submit_form($form_id, $form);
       drupal_redirect_form($form, $redirect);
     }
   }
 
-  $output = drupal_render_form($form_id, $form, $callback);
+  $output = drupal_render_form($form_id, $form, $function_prefix);
   list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals);
   return $output;
 }
@@ -69,11 +90,11 @@ function drupal_get_form($form_id, &$for
  *   theming, and hook_form_alter functions.
  * @param $form
  *   An associative array containing the structure of the form.
- * @param $callback
- *   An optional callback that will be used in addition to the form_id.
+ * @param $function_prefix
+ *   An optional function prefix that will be used in place of $form_id.
  *
  */
-function drupal_build_form($form_id, &$form, $callback = NULL) {
+function drupal_build_form($form_id, &$form, $function_prefix = NULL) {
   $form['#type'] = 'form';
   if (isset($form['#token'])) {
     // If the page cache is on and an anonymous user issues a GET request,
@@ -105,8 +126,8 @@ function drupal_build_form($form_id, &$f
     if (function_exists($form_id .'_validate')) {
       $form['#validate'] = array($form_id .'_validate' => array());
     }
-    elseif (function_exists($callback .'_validate')) {
-      $form['#validate'] = array($callback .'_validate' => array());
+    elseif (function_exists($function_prefix .'_validate')) {
+      $form['#validate'] = array($function_prefix .'_validate' => array());
     }
   }
 
@@ -116,8 +137,8 @@ function drupal_build_form($form_id, &$f
       // $form_values because it will change later
       $form['#submit'] = array($form_id .'_submit' => array());
     }
-    elseif (function_exists($callback .'_submit')) {
-      $form['#submit'] = array($callback .'_submit' => array());
+    elseif (function_exists($function_prefix .'_submit')) {
+      $form['#submit'] = array($function_prefix .'_submit' => array());
     }
   }
 
@@ -141,11 +162,9 @@ function drupal_build_form($form_id, &$f
  *   theming, and hook_form_alter functions.
  * @param $form
  *   An associative array containing the structure of the form.
- * @param $callback
- *   An optional callback that will be used in addition to the form_id.
  *
  */
-function drupal_validate_form($form_id, $form, $callback = NULL) {
+function drupal_validate_form($form_id, $form) {
   global $form_values;
   static $validated_forms = array();
 
@@ -175,14 +194,12 @@ function drupal_validate_form($form_id, 
  *   theming, and hook_form_alter functions.
  * @param $form
  *   An associative array containing the structure of the form.
- * @param $callback
- *   An optional callback that will be used in addition to the form_id.
  * @return
  *   A string containing the path of the page to display when processing
  *   is complete.
  *
  */
-function drupal_submit_form($form_id, $form, $callback = NULL) {
+function drupal_submit_form($form_id, $form) {
   global $form_values;
   $default_args = array($form_id, &$form_values);
 
@@ -209,21 +226,21 @@ function drupal_submit_form($form_id, $f
  *   theming, and hook_form_alter functions.
  * @param $form
  *   An associative array containing the structure of the form.
- * @param $callback
- *   An optional callback that will be used in addition to the form_id.
+ * @param $function_prefix
+ *   An optional function prefix that will be used in addition to the form_id.
  * @return
  *   A string containing the path of the page to display when processing
  *   is complete.
  *
  */
-function drupal_render_form($form_id, &$form, $callback = NULL) {
+function drupal_render_form($form_id, &$form, $function_prefix = NULL) {
   // Don't override #theme if someone already set it.
   if (!isset($form['#theme'])) {
     if (theme_get_function($form_id)) {
       $form['#theme'] = $form_id;
     }
-    elseif (theme_get_function($callback)) {
-      $form['#theme'] = $callback;
+    elseif (theme_get_function($function_prefix)) {
+      $form['#theme'] = $function_prefix;
     }
   }
 
=== modified file 'includes/menu.inc'
--- includes/menu.inc	
+++ includes/menu.inc	
@@ -415,7 +415,12 @@ function menu_execute_active_handler() {
     $arguments = array_merge($arguments, explode('/', $arg));
   }
 
-  return call_user_func_array($menu['callbacks'][$path]['callback'], $arguments);
+  $callback = $menu['callbacks'][$path]['callback'];
+  $return = call_user_func_array($callback, $arguments);
+  if (is_array($return)) {
+    return drupal_process_form($callback, $return);
+  }
+  return $return;
 }
 
 /**
=== modified file 'modules/aggregator/aggregator.module'
--- modules/aggregator/aggregator.module	
+++ modules/aggregator/aggregator.module	
@@ -332,7 +332,7 @@ function aggregator_block($op, $delta = 
     $form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']);
   }
 
-  return drupal_get_form('aggregator_form_category', $form);
+  return $form;
 }
 
 /**
@@ -463,7 +463,7 @@ function aggregator_form_feed($edit = ar
     $form['fid'] = array('#type' => 'hidden', '#value' => $edit['fid']);
   }
 
-  return drupal_get_form('aggregator_form_feed', $form);
+  return $form;
 }
 
 /**
@@ -1045,28 +1045,15 @@ function aggregator_page_category() {
   return _aggregator_page_list('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = '. $category->cid .' ORDER BY timestamp DESC, iid DESC', arg(3));
 }
 
-/**
- * Prints an aggregator page listing a number of feed items. Various
- * menu callbacks use this function to print their feeds.
- */
-function _aggregator_page_list($sql, $op, $header = '') {
-  $categorize = (user_access('administer news feeds') && ($op == 'categorize'));
-
-  $output = '<div id="aggregator">';
-
+function aggregator_page_list($sql, $header, $categorize) {
   $form['header'] = array('#value' => $header);
-  $output .= $form['header']['#value'];
-
   $result = pager_query($sql, 20);
   $categories = array();
   $done = FALSE;
   while ($item = db_fetch_object($result)) {
     $form['items'][$item->iid] = array('#value' => theme('aggregator_page_item', $item));
-    $output .= $form['items'][$item->iid]['#value'];
     $form['categories'][$item->iid] = array();
-
     if ($categorize) {
-
       $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = %d', $item->iid);
       $selected = array();
       while ($category = db_fetch_object($categories_result)) {
@@ -1085,11 +1072,8 @@ function _aggregator_page_list($sql, $op
       );
     }
   }
-  $output .= '</div>';
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save categories'));
   $form['pager'] = array('#value' => theme('pager', NULL, 20, 0));
-  $output .= $form['pager']['#value'];
-
   // arg(1) is undefined if we are at the top aggregator URL
   // is there a better way to do this?
   if (!arg(1)) {
@@ -1098,9 +1082,30 @@ function _aggregator_page_list($sql, $op
   elseif (arg(1) == 'categories' && arg(2) && !arg(3)) {
     $form['feed_icon'] = array('#value' => theme('feed_icon', url('aggregator/rss/' . arg(2))));
   }
-  $output .= $form['feed_icon']['#value'];
+  return $form;
+}
 
-  return ($categorize) ? drupal_get_form('aggregator_page_list', $form) : $output;
+/**
+ * Prints an aggregator page listing a number of feed items. Various
+ * menu callbacks use this function to print their feeds.
+ */
+function _aggregator_page_list($sql, $op, $header = '') {
+  $categorize = (user_access('administer news feeds') && ($op == 'categorize'));
+  $form = aggregator_page_list($sql, $header, $categorize);
+  if ($categorize) {
+    return $form;
+  }
+  else {
+    $output = '<div id="aggregator">';
+    $output .= $header;
+    foreach ($form['items'] as $item) {
+      $output .= $item['#value'];
+    }
+    $output .= '</div>';
+    $output .= $form['pager']['#value'];
+    $output .= $form['feed_icon']['#value'];
+    return $output;
+  }
 }
 
 function theme_aggregator_page_list($form) {
=== modified file 'modules/block/block.module'
--- modules/block/block.module	
+++ modules/block/block.module	
@@ -84,7 +84,7 @@ function block_menu($may_cache) {
       'type' => MENU_CALLBACK);
     $items[] = array('path' => 'admin/build/block/add', 'title' => t('add block'),
       'access' => user_access('administer blocks'),
-      'callback' => 'block_box_add',
+      'callback' => 'block_box_form',
       'type' => MENU_LOCAL_TASK);
     foreach (list_themes() as $key => $theme) {
       if ($theme->status) {
@@ -240,7 +240,7 @@ function block_admin_display($theme = NU
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save blocks'));
 
-  return drupal_get_form('block_admin_display', $form);
+  return $form;
 }
 
 /**
@@ -463,7 +463,7 @@ function block_admin_configure($module =
     '#value' => t('Save block'),
   );
 
-  return drupal_get_form('block_admin_configure', $form);
+  return $form;
 }
 
 function block_admin_configure_validate($form_id, $form_values) {
@@ -488,16 +488,6 @@ function block_admin_configure_submit($f
   }
 }
 
-/**
- * Menu callback; displays the block creation form.
- */
-function block_box_add() {
-  $form = block_box_form();
-  $form['submit'] = array('#type' => 'submit', '#value' => t('Save block'));
-
-  return drupal_get_form('block_box_add', $form);
-}
-
 function block_box_add_validate($form_id, $form_values) {
   if (empty($form_values['info']) || db_num_rows(db_query("SELECT info FROM {boxes} WHERE info = '%s'", $form_values['info']))) {
     form_set_error('info', t('Please ensure that each block description is unique.'));
@@ -562,6 +552,7 @@ function block_box_form($edit = array())
     '#weight' => -17,
   );
   $form['body_filter']['format'] = filter_form($edit['format'], -16);
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Save block'));
 
   return $form;
 }
=== modified file 'modules/book/book.module'
--- modules/book/book.module	
+++ modules/book/book.module	
@@ -320,7 +320,7 @@ function book_outline($nid) {
   }
 
   drupal_set_title(check_plain($node->title));
-  return drupal_get_form('book_outline', $form);
+  return $form;
 }
 
 /**
@@ -887,7 +887,7 @@ function book_admin_edit($nid) {
       '#value' => t('Save book pages'),
     );
 
-    return drupal_get_form('book_admin_edit', $form);
+    return $form;
   }
   else {
     drupal_not_found();
@@ -915,19 +915,17 @@ function book_admin_orphan() {
   }
 
   if (count($orphans)) {
-    $form = array();
-
     $form['table'] = _book_admin_table($orphans);
     $form['save'] = array(
       '#type' => 'submit',
       '#value' => t('Save book pages'),
     );
 
-    return drupal_get_form('book_admin_edit', $form);
   }
   else {
-    return '<p>'. t('There are no orphan pages.') .'</p>';
+    $form['error'] = array('#value' => '<p>'. t('There are no orphan pages.') .'</p>');
   }
+  return $form;
 }
 
 function book_admin_edit_submit($form_id, $form_values) {
=== modified file 'modules/comment/comment.module'
--- modules/comment/comment.module	
+++ modules/comment/comment.module	
@@ -891,7 +891,7 @@ function comment_render($node, $cid = 0)
       // Start a form, for use with comment control.
       $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
       if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
-        $output .= comment_controls($mode, $order, $comments_per_page);
+        $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
       }
 
       while ($comment = db_fetch_object($result)) {
@@ -916,7 +916,7 @@ function comment_render($node, $cid = 0)
       $output .= theme('pager', NULL, $comments_per_page, 0);
 
       if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
-        $output .= comment_controls($mode, $order, $comments_per_page);
+        $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
       }
     }
 
@@ -1043,7 +1043,7 @@ function comment_admin_overview($type = 
   }
   $form['comments'] = array('#type' => 'checkboxes', '#options' => $comments);
   $form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
-  return drupal_get_form('comment_admin_overview', $form);
+  return $form;
 }
 
 /**
@@ -1274,7 +1274,7 @@ function comment_validate($edit) {
 ** This is rendered by theme_comment_form.
 */
 
-function comment_form($edit, $title = NULL) {
+function _comment_form($edit, $title = NULL) {
   global $user;
 
   $op = isset($_POST['op']) ? $_POST['op'] : '';
@@ -1421,8 +1421,12 @@ function comment_form($edit, $title = NU
 
   // Graft in extra form additions
   $form = array_merge($form, comment_invoke_comment($form, 'form'));
+  $form['#form_id'] = 'comment_form';
+  return $form;
+}
 
-  return theme('box', $title, drupal_get_form('comment_form', $form));
+function comment_form($edit, $title = NULL) {
+  return theme('box', $title, drupal_get_form('_comment_form', $edit, $title));
 }
 
 function comment_form_add_preview($form, $edit) {
@@ -1575,7 +1579,7 @@ function comment_controls($mode = COMMEN
     '#weight' => 20,
   );
 
-  return drupal_get_form('comment_controls', $form);
+  return $form;
 }
 
 function theme_comment_controls($form) {
=== modified file 'modules/contact/contact.module'
--- modules/contact/contact.module	
+++ modules/contact/contact.module	
@@ -100,7 +100,6 @@ function contact_menu($may_cache) {
       global $user;
       $account = user_load(array('uid' => arg(1)));
       if (($user->uid != $account->uid && $account->contact) || user_access('administer users')) {
-        global $user;
         $items[] = array('path' => 'user/'. arg(1) .'/contact',
           'title' => t('contact'),
           'callback' => 'contact_mail_user',
@@ -199,7 +198,7 @@ function contact_admin_edit($cid = NULL)
     '#value' => t('Submit'),
   );
 
-  return drupal_get_form('contact_admin_edit', $form);
+  return $form;
 }
 
 /**
@@ -297,14 +296,7 @@ function contact_admin_settings() {
     '#default_value' => variable_get('contact_default_status', 1),
     '#description' => t('Default status of the personal contact form for new users.'),
   );
-  $form['submit'] = array('#type' => 'submit',
-    '#value' => t('Save configuration'),
-  );
-  $form['reset'] = array('#type' => 'submit',
-    '#value' => t('Reset to defaults'),
-  );
-
-  return drupal_get_form('contact_admin_settings', $form, 'system_settings_form');
+  return system_settings_form($form);
 }
 
 /**
@@ -322,33 +314,7 @@ function contact_mail_user() {
     }
     else {
       drupal_set_title($account->name);
-
-      $form['#token'] = $user->name . $user->mail;
-      $form['from'] = array('#type' => 'item',
-        '#title' => t('From'),
-        '#value' => $user->name .' &lt;'. $user->mail .'&gt;',
-      );
-      $form['to'] = array('#type' => 'item',
-        '#title' => t('To'),
-        '#value' => $account->name,
-      );
-      $form['subject'] = array('#type' => 'textfield',
-        '#title' => t('Subject'),
-        '#maxlength' => 50,
-        '#required' => TRUE,
-      );
-      $form['message'] = array('#type' => 'textarea',
-        '#title' => t('Message'),
-        '#rows' => 15,
-        '#required' => TRUE,
-      );
-      $form['copy'] = array('#type' => 'checkbox',
-        '#title' => t('Send me a copy.'),
-      );
-      $form['submit'] = array('#type' => 'submit',
-        '#value' => t('Send e-mail'),
-      );
-      $output = drupal_get_form('contact_mail_user', $form);
+      $output = drupal_get_form('contact_mail_user_form');
     }
 
     return $output;
@@ -358,6 +324,37 @@ function contact_mail_user() {
   }
 }
 
+function contact_mail_user_form() {
+  global $user;
+  $form['#token'] = $user->name . $user->mail;
+  $form['from'] = array('#type' => 'item',
+    '#title' => t('From'),
+    '#value' => $user->name .' &lt;'. $user->mail .'&gt;',
+  );
+  $form['to'] = array('#type' => 'item',
+    '#title' => t('To'),
+    '#value' => $account->name,
+  );
+  $form['subject'] = array('#type' => 'textfield',
+    '#title' => t('Subject'),
+    '#maxlength' => 50,
+    '#required' => TRUE,
+  );
+  $form['message'] = array('#type' => 'textarea',
+    '#title' => t('Message'),
+    '#rows' => 15,
+    '#required' => TRUE,
+  );
+  $form['copy'] = array('#type' => 'checkbox',
+    '#title' => t('Send me a copy.'),
+  );
+  $form['submit'] = array('#type' => 'submit',
+    '#value' => t('Send e-mail'),
+  );
+  $form['#form_id'] = 'contact_mail_user';
+  return $form;
+}
+
 /**
  * Process the personal contact page form submission.
  */
@@ -416,77 +413,79 @@ function contact_mail_page() {
     $output = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3)));
   }
   else {
-    if ($user->uid) {
-      $edit['name'] = $user->name;
-      $edit['mail'] = $user->mail;
-    }
+    $output = drupal_get_form('contact_mail_page_form');
+  }
 
-    $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category');
-    while ($category = db_fetch_object($result)) {
-      $categories[$category->cid] = $category->category;
-      if ($category->selected) {
-        $default_category = $category->cid;
-      }
-    }
+  return $output;
+}
 
-    if (count($categories) > 0) {
-      $form['#token'] = $user->name . $user->mail;
-      $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.'))));
-      $form['name'] = array('#type' => 'textfield',
-        '#title' => t('Your name'),
-        '#maxlength' => 255,
-        '#default_value' => $edit['name'],
-        '#required' => TRUE,
-      );
-      $form['mail'] = array('#type' => 'textfield',
-        '#title' => t('Your e-mail address'),
-        '#maxlength' => 255,
-        '#default_value' => $edit['mail'],
-        '#required' => TRUE,
-      );
-      $form['subject'] = array('#type' => 'textfield',
-        '#title' => t('Subject'),
-        '#maxlength' => 255,
-        '#required' => TRUE,
-      );
-      if (count($categories) > 1) {
-        // If there is more than one category available and no default category has been selected,
-        // prepend a default placeholder value.
-        if (!isset($default_category)) {
-          $categories = array(t('--')) + $categories;
-        }
-        $form['cid'] = array('#type' => 'select',
-          '#title' => t('Category'),
-          '#default_value' => $default_category,
-          '#options' => $categories,
-          '#required' => TRUE,
-        );
-      }
-      else {
-        // If there is only one category, store its cid.
-        $category_keys = array_keys($categories);
-        $form['cid'] = array('#type' => 'value',
-          '#value' => array_shift($category_keys),
-        );
+function contact_mail_page_form() {
+  global $user;
+
+  $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category');
+  while ($category = db_fetch_object($result)) {
+    $categories[$category->cid] = $category->category;
+    if ($category->selected) {
+      $default_category = $category->cid;
+    }
+  }
+  
+  if (count($categories) > 0) {
+    $form['#token'] = $user->name . $user->mail;
+    $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.'))));
+    $form['name'] = array('#type' => 'textfield',
+      '#title' => t('Your name'),
+      '#maxlength' => 255,
+      '#default_value' => $user->uid ? $user->name : '',
+      '#required' => TRUE,
+    );
+    $form['mail'] = array('#type' => 'textfield',
+      '#title' => t('Your e-mail address'),
+      '#maxlength' => 255,
+      '#default_value' => $user->uid ? $user->mail : '',
+      '#required' => TRUE,
+    );
+    $form['subject'] = array('#type' => 'textfield',
+      '#title' => t('Subject'),
+      '#maxlength' => 255,
+      '#required' => TRUE,
+    );
+    if (count($categories) > 1) {
+      // If there is more than one category available and no default category has been selected,
+      // prepend a default placeholder value.
+      if (!isset($default_category)) {
+        $categories = array(t('--')) + $categories;
       }
-      $form['message'] = array('#type' => 'textarea',
-        '#title' => t('Message'),
+      $form['cid'] = array('#type' => 'select',
+        '#title' => t('Category'),
+        '#default_value' => $default_category,
+        '#options' => $categories,
         '#required' => TRUE,
       );
-      $form['copy'] = array('#type' => 'checkbox',
-        '#title' => t('Send me a copy.'),
-      );
-      $form['submit'] = array('#type' => 'submit',
-        '#value' => t('Send e-mail'),
-      );
-      $output = drupal_get_form('contact_mail_page', $form);
     }
     else {
-      $output = t('The contact form has not been configured.');
+      // If there is only one category, store its cid.
+      $category_keys = array_keys($categories);
+      $form['cid'] = array('#type' => 'value',
+        '#value' => array_shift($category_keys),
+      );
     }
+    $form['message'] = array('#type' => 'textarea',
+      '#title' => t('Message'),
+      '#required' => TRUE,
+    );
+    $form['copy'] = array('#type' => 'checkbox',
+      '#title' => t('Send me a copy.'),
+    );
+    $form['submit'] = array('#type' => 'submit',
+      '#value' => t('Send e-mail'),
+    );
   }
-
-  return $output;
+  else {
+    $form['#error'] = array('#value' => t('The contact form has not been configured.'));
+  }
+  $form['#form_id'] = 'contact_mail_page';
+  return $form;
 }
 
 /**
=== modified file 'modules/filter/filter.module'
--- modules/filter/filter.module	
+++ modules/filter/filter.module	
@@ -316,7 +316,7 @@ function filter_admin_overview() {
   }
   $form['default'] = array('#type' => 'radios', '#options' => $options, '#default_value' => variable_get('filter_default_format', 1));
   $form['submit'] = array('#type' => 'submit', '#value' => t('Set default format'));
-  return drupal_get_form('filter_admin_overview', $form);
+  return $form;
 }
 
 function filter_admin_overview_submit($form_id, $form_values) {
@@ -440,8 +440,6 @@ function filter_admin_format_form($forma
       '#description' => module_invoke($filter->module, 'filter', 'description', $filter->delta),
     );
   }
-  $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
-
   if (isset($format)) {
     $form['format'] = array('#type' => 'hidden', '#value' => $format->format);
 
@@ -454,11 +452,11 @@ function filter_admin_format_form($forma
     }
     $group = t('<p>These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.</p>');
     $group .= $tiplist;
-    $output = '<h2>'. t('Formatting guidelines') .'</h2>'. $group;
+    $form['tips'] = array('#value' => '<h2>'. t('Formatting guidelines') .'</h2>'. $group);
   }
-  $output = drupal_get_form('filter_admin_format_form', $form) . $output;
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
-  return $output;
+  return $form;
 }
 
 /**
@@ -549,7 +547,7 @@ function filter_admin_order($format = NU
   $form['format'] = array('#type' => 'hidden', '#value' => $format->format);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
-  return drupal_get_form('filter_admin_order', $form);
+  return $form;
 }
 
 /**
=== modified file 'modules/forum/forum.module'
--- modules/forum/forum.module	
+++ modules/forum/forum.module	
@@ -476,8 +476,9 @@ function forum_form_container($edit = ar
     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
     $form['tid'] = array('#type' => 'value', '#value' => $edit['tid']);
   }
+  $form['#function_prefix'] = 'forum_form';
 
-  return drupal_get_form('forum_form_container', $form, 'forum_form');
+  return $form;
 }
 
 /**
@@ -517,8 +518,9 @@ function forum_form_forum($edit = array(
     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
     $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']);
   }
+  $form['#function_prefix'] = 'forum_form';
 
-  return drupal_get_form('forum_form_forum', $form, 'forum_form');
+  return $form;
 }
 
 /**
=== modified file 'modules/menu/menu.module'
--- modules/menu/menu.module	
+++ modules/menu/menu.module	
@@ -331,9 +331,10 @@ function menu_edit_menu_form($type, $mid
   $form['weight'] = array('#type' => 'value', '#value' => $item['weight']);
   $form['type'] = array('#type' => 'value', '#value' => $item['type']);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
-
   // Reuse the submit function of menu_edit_item_form.
-  return drupal_get_form('menu_edit_menu_form', $form, 'menu_edit_item_form');
+  $form['#function_prefix'] = 'menu_edit_item_form';
+  
+  return $form;
 }
 
 /**
@@ -411,7 +412,7 @@ function menu_edit_item_form($type, $mid
   $form['mid'] = array('#type' => 'value', '#value' => $item['mid']);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
 
-  return drupal_get_form('menu_edit_item_form', $form);
+  return $form;
 }
 
 /**
=== modified file 'modules/node/node.module'
--- modules/node/node.module	
+++ modules/node/node.module	
@@ -1288,13 +1288,13 @@ function node_filter_form() {
     $form['filters']['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
   }
 
-  return drupal_get_form('node_filter_form', $form);
+  return $form;
 }
 
 /**
  * Theme node administration filter form.
  */
-function theme_node_filter_form(&$form) {
+function theme_node_filter_form($form) {
   $output .= '<div id="node-admin-filter">';
   $output .= drupal_render($form['filters']);
   $output .= '</div>';
@@ -1305,7 +1305,7 @@ function theme_node_filter_form(&$form) 
 /**
  * Theme node administraton filter selector.
  */
-function theme_node_filters(&$form) {
+function theme_node_filters($form) {
   $output .= '<ul>';
   if (sizeof($form['current'])) {
     foreach (element_children($form['current']) as $key) {
@@ -1394,13 +1394,19 @@ function node_admin_nodes_validate($form
  * Menu callback: content administration.
  */
 function node_admin_nodes() {
-  global $form_values;
-  $output = node_filter_form();
+  $output = drupal_get_form('node_filter_form');
 
   if ($_POST['edit']['operation'] == 'delete' && $_POST['edit']['nodes']) {
     return node_multiple_delete_confirm();
   }
+  // Call the form first, to allow for the form_values array to be populated.
+  $output .= drupal_get_form('node_admin_form');
+  
+  return $output;
+}
 
+function node_admin_form() {
+  global $form_values;
   $filter = node_build_filter_query();
 
   $result = pager_query('SELECT n.*, u.name, u.uid FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] .' ORDER BY n.changed DESC', 50, 0, NULL, $filter['args']);
@@ -1428,11 +1434,8 @@ function node_admin_nodes() {
   }
   $form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
   $form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
-
-  // Call the form first, to allow for the form_values array to be populated.
-  $output .= drupal_get_form('node_admin_nodes', $form);
-
-  return $output;
+  $form['#form_id'] = 'node_admin_nodes';
+  return $form;
 }
 
 /**
@@ -1824,18 +1827,10 @@ function node_object_prepare(&$node) {
 }
 
 /**
- * Generate the node editing form.
+ * Generate the node editing form array
  */
 function node_form($node) {
   $node = (object)$node;
-  $form = node_form_array($node);
-  return drupal_get_form($node->type .'_node_form', $form, 'node_form');
-}
-
-/**
- * Generate the node editing form array.
- */
-function node_form_array($node) {
   node_object_prepare($node);
 
   // Set the id of the top-level form tag
@@ -1903,8 +1898,11 @@ function node_form_array($node) {
   if ($node->nid && node_access('delete', $node)) {
     $form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 50);
   }
-
-  $form['#after_build'] = array('node_form_add_preview');
+  $form += array(
+    '#after_build' => array('node_form_add_preview'),
+    '#form_id' => $node->type .'_node_form',
+    '#function_prefix' => 'node_form',
+  );
 
   return $form;
 }
@@ -2807,7 +2805,8 @@ function node_access_rebuild_page() {
     '#type' => 'submit',
     '#value' => t('Rebuild node access'),
   );
-  return drupal_get_form('node_access_rebuild', $form);
+  $form['#form_id'] = 'node_access_rebuild';
+  return $form;
 }
 
 /**
=== modified file 'modules/path/path.module'
--- modules/path/path.module	
+++ modules/path/path.module	
@@ -193,7 +193,7 @@ function path_form($edit = '') {
     $form['submit'] = array('#type' => 'submit', '#value' => t('Create new alias'));
   }
 
-  return drupal_get_form('path_form', $form);
+  return $form;
 }
 
 /**
=== modified file 'modules/poll/poll.module'
--- modules/poll/poll.module	
+++ modules/poll/poll.module	
@@ -317,11 +317,7 @@ function poll_teaser($node) {
 /**
  * Generates the voting form for a poll.
  */
-function poll_view_voting(&$node, $teaser, $page, $block) {
-  if ($_POST['op'] == t('Vote')) {
-    poll_vote($node);
-  }
-
+function poll_view_voting($node, $page) {
   if ($node->choice) {
     $list = array();
     foreach ($node->choice as $i => $choice) {
@@ -332,7 +328,7 @@ function poll_view_voting(&$node, $tease
   $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
   $form['vote'] = array('#type' => 'submit', '#value' => t('Vote'));
   $form['#action'] = url('node/'. $node->nid);
-  return drupal_get_form('poll_view_voting', $form);
+  return $form;
 }
 
 /**
@@ -387,10 +383,7 @@ function theme_poll_results($title, $res
     $output .= $results;
     $output .= '<div class="total">'. t('Total votes: %votes', array('%votes' => $votes)) .'</div>';
     if (isset($vote) && $vote > -1 && user_access('cancel own vote')) {
-      $form['#action'] = url("poll/cancel/$nid");
-      $form['choice'] = array('#type' => 'hidden', '#value' => $vote);
-      $form['submit'] = array('#type' => 'submit', '#value' => t('Cancel your vote'));
-      $output .= drupal_get_form('poll_cancel_form', $form);
+      $output .= drupal_get_form('poll_cancel_form', $nid, $vote);
     }
     $output .= '</div>';
   }
@@ -398,6 +391,13 @@ function theme_poll_results($title, $res
   return $output;
 }
 
+function poll_cancel_form($nid, $vote) {
+  $form['#action'] = url("poll/cancel/$nid");
+  $form['choice'] = array('#type' => 'hidden', '#value' => $vote);
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Cancel your vote'));
+  return $form;
+}
+
 function theme_poll_bar($title, $percentage, $votes, $block) {
   if ($block) {
     $output  = '<div class="text">'. $title .'</div>';
@@ -559,8 +559,11 @@ function poll_view($node, $teaser = FALS
   }
 
   if ($node->allowvotes && ($block || arg(2) != 'results')) {
+    if ($_POST['op'] == t('Vote')) {
+      poll_vote($node);
+    }
     $node->content['body'] = array(
-      '#value' => poll_view_voting($node, $teaser, $page, $block),
+      '#value' => drupal_get_form('poll_view_voting', $node, $page),
     );
   }
   else {
=== modified file 'modules/profile/profile.module'
--- modules/profile/profile.module	
+++ modules/profile/profile.module	
@@ -291,7 +291,7 @@ function profile_field_form($arg = NULL)
   $form['submit'] = array('#type' => 'submit',
     '#value' => t('Save field'),
   );
-  return drupal_get_form('profile_field_form', $form);
+  return $form;
 }
 
 /**
=== modified file 'modules/search/search.module'
--- modules/search/search.module	
+++ modules/search/search.module	
@@ -138,7 +138,7 @@ function search_block($op = 'list', $del
     return $blocks;
   }
   else if ($op == 'view' && user_access('search content')) {
-    $block['content'] = search_box('search_block_form');
+    $block['content'] = drupal_get_form('search_box', 'search_block_form');
     $block['subject'] = t('Search');
     return $block;
   }
@@ -1005,7 +1005,7 @@ function search_form($action = '', $keys
   $form['basic']['inline']['processed_keys'] = array('#type' => 'value', '#value' => array());
   $form['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
 
-  return drupal_get_form('search_form', $form);
+  return $form;
 }
 
 /**
@@ -1047,8 +1047,10 @@ function search_box($form_id = 'search_t
   // Always go to the search page since the search form is not guaranteed to be
   // on every page.
   $form['#action'] = url('search/node');
+  $form['#form_id'] = $form_id;
+  $form['#function_prefix'] = 'search_box_form';
 
-  return drupal_get_form($form_id, $form, 'search_box_form');
+  return $form;
 }
 
 /**
=== modified file 'modules/system/system.module'
--- modules/system/system.module	
+++ modules/system/system.module	
@@ -361,7 +361,7 @@ function system_admin_theme_settings() {
   $form['#submit']['system_admin_theme_submit'] = array();
   $form['#submit']['system_settings_form_submit'] = array();
 
-  return system_settings_form('system_admin_theme_form', $form);
+  return system_settings_form($form);
 }
 
 
@@ -498,7 +498,7 @@ function system_site_information_setting
     '#description' => t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".')
   );
 
-  return system_settings_form('system_site_information_settings', $form);
+  return system_settings_form($form);
 }
 
 function system_clean_url_settings() {
@@ -522,7 +522,7 @@ function system_clean_url_settings() {
     }
   }
 
-  return system_settings_form('system_clean_url_settings', $form);
+  return system_settings_form($form);
 }
 
 function system_error_reporting_settings() {
@@ -557,7 +557,7 @@ function system_error_reporting_settings
     '#description' => t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.')
   );
 
-  return system_settings_form('system_error_reporting_settings', $form);
+  return system_settings_form($form);
 }
 
 function system_page_caching_settings() {
@@ -580,7 +580,7 @@ function system_page_caching_settings() 
     '#description' => t('Enabling the cache will offer a sufficient performance boost for most low-traffic and medium-traffic sites. On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
   );
 
-  return system_settings_form('system_page_caching_settings', $form);
+  return system_settings_form($form);
 }
 
 function system_file_system_settings() {
@@ -611,7 +611,7 @@ function system_file_system_settings() {
     '#description' => t('If you want any sort of access control on the downloading of files, this needs to be set to <em>private</em>. You can change this at any time, however all download URLs will change and there may be unexpected problems so it is not recommended.')
   );
 
-  return system_settings_form('system_file_system_settings', $form);
+  return system_settings_form($form);
 }
 
 function system_image_toolkit_settings() {
@@ -624,10 +624,11 @@ function system_image_toolkit_settings()
       '#options' => $toolkits_available
     );
 
-    return system_settings_form('system_image_toolkit_settings', $form);
+    return system_settings_form($form);
   }
   else {
-    return '<p>'. t("No image toolkits found.  Drupal will use PHP's built-in GD library for image handling.") .'</p>';
+    $form['error'] = array('#value' => '<p>'. t("No image toolkits found.  Drupal will use PHP's built-in GD library for image handling.") .'</p>');
+    return $form;
   }
 }
 
@@ -648,7 +649,7 @@ function system_rss_feeds_settings() {
     '#description' => t('Global setting for the length of XML feed items that are output by default.')
   );
 
-  return system_settings_form('system_rss_feeds_settings', $form);
+  return system_settings_form($form);
 }
 
 function system_date_time_settings() {
@@ -726,7 +727,7 @@ function system_date_time_settings() {
     '#description' => t('The first day of the week for calendar views.')
   );
 
-  return system_settings_form('system_date_time_settings', $form);
+  return system_settings_form($form);
 }
 
 function system_site_status_settings() {
@@ -746,11 +747,12 @@ function system_site_status_settings() {
     '#description' => t('Message to show visitors when the site is in off-line mode.')
   );
 
-  return system_settings_form('system_site_status_settings', $form);
+  return system_settings_form($form);
 }
 
 function system_unicode_settings() {
-  return system_settings_form('system_unicode_settings', unicode_settings());
+  $form = unicode_settings();
+  return system_settings_form($form);
 }
 
 function system_cron_status($cron = '') {
@@ -1018,16 +1020,18 @@ function system_initialize_theme_blocks(
   }
 }
 
-// Add the submit / reset buttons and run drupal_get_form()
-function system_settings_form($form_id, $form) {
+/**
+ * Add default buttons to a form and set its prefix
+ */
+function system_settings_form($form) {
   $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
   $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
 
   if (!empty($_POST) && form_get_errors()) {
     drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
   }
-
-  return drupal_get_form($form_id, $form, 'system_settings_form');
+  $form['#function_prefix'] = 'system_settings_form';
+  return $form;
 }
 
 function system_theme_settings_submit($form_id, $values) {
@@ -1111,7 +1115,7 @@ function system_themes() {
   $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
   $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
 
-  return drupal_get_form('system_themes', $form);
+  return $form;
 }
 
 function theme_system_themes($form) {
@@ -1210,7 +1214,7 @@ function system_modules() {
 
   $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
-  return drupal_get_form('system_modules', $form);
+  return $form;
 }
 
 function theme_system_modules($form) {
@@ -1480,8 +1484,7 @@ function system_theme_settings($key = ''
   }
   $form['#attributes'] = array('enctype' => 'multipart/form-data');
 
-  return system_settings_form('system_theme_settings', $form);
-
+  return system_settings_form($form);
 }
 
 /**
@@ -1527,7 +1530,7 @@ function confirm_form($form_id, $form, $
   $form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
   $form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm'));
   $form['actions']['cancel'] = array('#value' => l($no ? $no : t('Cancel'), $path));
-  return drupal_get_form($form_id, $form, 'confirm_form');
+  return $form;
 }
 
 /**
=== modified file 'modules/taxonomy/taxonomy.module'
--- modules/taxonomy/taxonomy.module	
+++ modules/taxonomy/taxonomy.module	
@@ -260,7 +260,7 @@ function taxonomy_form_vocabulary($edit 
     $form['vid'] = array('#type' => 'value', '#value' => $edit['vid']);
     $form['module'] = array('#type' => 'value', '#value' => $edit['module']);
   }
-  return drupal_get_form('taxonomy_form_vocabulary', $form);
+  return $form;
 }
 
 /**
@@ -401,7 +401,7 @@ function taxonomy_form_term($edit = arra
     $form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']);
   }
 
-  return drupal_get_form('taxonomy_form_term', $form);
+  return $form;
 }
 
 /**
=== modified file 'modules/user/user.module'
--- modules/user/user.module	
+++ modules/user/user.module	
@@ -469,6 +469,35 @@ function user_user($type, &$edit, &$user
   }
 }
 
+function user_login_block() {
+  $form = array(
+    '#action' => url($_GET['q'], drupal_get_destination()),
+    '#id' => 'user-login-form',
+    '#function_prefix' => 'user_login',
+  );
+  $form['name'] = array('#type' => 'textfield',
+    '#title' => t('Username'),
+    '#maxlength' => 60,
+    '#size' => 15,
+    '#required' => TRUE,
+  );
+  $form['pass'] = array('#type' => 'password',
+    '#title' => t('Password'),
+    '#size' => 15,
+    '#required' => TRUE,
+  );
+  $form['submit'] = array('#type' => 'submit',
+    '#value' => t('Log in'),
+  );
+  $items = array();
+  if (variable_get('user_register', 1)) {
+    $items[] = l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.')));
+  }
+  $items[] = l(t('Request new password'), 'user/password', array('title' => t('Request new password via e-mail.')));
+  $form['links'] = array('#value' => theme('item_list', $items));
+  return $form;
+}
+
 /**
  * Implementation of hook_block().
  */
@@ -501,31 +530,9 @@ function user_block($op = 'list', $delta
       case 0:
         // For usability's sake, avoid showing two login forms on one page.
         if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
-          $form['#action'] = url($_GET['q'], drupal_get_destination());
-          $form['#id'] = 'user-login-form';
-          $form['name'] = array('#type' => 'textfield',
-            '#title' => t('Username'),
-            '#maxlength' => 60,
-            '#size' => 15,
-            '#required' => TRUE,
-          );
-          $form['pass'] = array('#type' => 'password',
-            '#title' => t('Password'),
-            '#size' => 15,
-            '#required' => TRUE,
-          );
-          $form['submit'] = array('#type' => 'submit',
-            '#value' => t('Log in'),
-          );
-
-          if (variable_get('user_register', 1)) {
-            $items[] = l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.')));
-          }
-          $items[] = l(t('Request new password'), 'user/password', array('title' => t('Request new password via e-mail.')));
-          $form['links'] = array('#value' => theme('item_list', $items));
 
           $block['subject'] = t('User login');
-          $block['content'] = drupal_get_form('user_login_block', $form, 'user_login');
+          $block['content'] = drupal_get_form('user_login_block');
         }
         return $block;
 
@@ -876,7 +883,7 @@ function user_login($msg = '') {
     '#attributes' => array('tabindex' => '2'),
   );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'), '#weight' => 2, '#attributes' => array('tabindex' => '3'));
-  return drupal_get_form('user_login', $form);
+  return $form;
 }
 
 function user_login_validate($form_id, $form_values) {
@@ -1008,7 +1015,7 @@ function user_pass() {
     '#value' => t('E-mail new password'),
     '#weight' => 2,
   );
-  return drupal_get_form('user_pass', $form);
+  return $form;
 }
 
 function user_pass_validate() {
@@ -1098,7 +1105,7 @@ function user_pass_reset($uid, $timestam
           $form['help'] = array('#value' => t('<p>This login can be used only once.</p>'));
           $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'));
           $form['#action'] = url("user/reset/$uid/$timestamp/$hashed_pass/login");
-          return drupal_get_form('user_pass_reset', $form);
+          return $form;
         }
       }
       else {
@@ -1174,7 +1181,7 @@ function user_register() {
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Create new account'), '#weight' => 30);
 
-  return drupal_get_form('user_register', $form);
+  return $form;
 }
 
 function user_register_validate($form_id, $form_values) {
@@ -1404,7 +1411,7 @@ function user_edit($category = 'account'
   $form['#attributes']['enctype'] = 'multipart/form-data';
 
   drupal_set_title($account->name);
-  return drupal_get_form('user_edit', $form);
+  return $form;
 }
 
 /**
@@ -1511,31 +1518,43 @@ function _user_mail_text($messageid, $va
   }
 }
 
-/**
- * Menu callback: check an access rule
- */
-function user_admin_access_check() {
+function user_admin_check_user() {
   $form['user'] = array('#type' => 'fieldset', '#title' => t('Username'));
   $form['user']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a username to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64);
   $form['user']['type'] = array('#type' => 'hidden', '#value' => 'user');
   $form['user']['submit'] = array('#type' => 'submit', '#value' => t('Check username'));
-  $output .= drupal_get_form('check_user', $form, 'user_admin_access_check');
-  unset($form); // prevent endless loop?
+  $form['#function_prefix'] = 'user_admin_access_check';
+  $form['#form_id'] = 'check_user';
+  return $form;
+}
 
+function user_admin_check_mail() {
   $form['mail'] = array('#type' => 'fieldset', '#title' => t('E-mail'));
   $form['mail']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter an e-mail address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64);
   $form['mail']['type'] = array('#type' => 'hidden', '#value' => 'mail');
   $form['mail']['submit'] = array('#type' => 'submit', '#value' => t('Check e-mail'));
-  $output .= drupal_get_form('check_mail', $form, 'user_admin_access_check');
-  unset($form); // prevent endless loop?
+  $form['#function_prefix'] = 'user_admin_access_check';
+  $form['#form_id'] = 'check_mail';
+  return $form;
+}
 
+function user_admin_check_host() {
   $form['host'] = array('#type' => 'fieldset', '#title' => t('Hostname'));
   $form['host']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a hostname or IP address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64);
   $form['host']['type'] = array('#type' => 'hidden', '#value' => 'host');
   $form['host']['submit'] = array('#type' => 'submit', '#value' => t('Check hostname'));
-  $output .= drupal_get_form('check_host', $form, 'user_admin_access_check');
-  unset($form); // prevent endless loop?
+  $form['#function_prefix'] = 'user_admin_access_check';
+  $form['#form_id'] = 'check_host';
+  return $form;
+}
 
+/**
+ * Menu callback: check an access rule
+ */
+function user_admin_access_check() {
+  $output = drupal_get_form('user_admin_check_user');
+  $output .= drupal_get_form('user_admin_check_mail');
+  $output .= drupal_get_form('user_admin_check_host');
   return $output;
 }
 
@@ -1596,10 +1615,7 @@ function user_admin_access_add($mask = N
     $edit['type'] = $type;
   }
 
-  $form = _user_admin_access_form($edit);
-  $form['submit'] = array('#type' => 'submit', '#value' => t('Add rule'));
-
-  return drupal_get_form('access_rule', $form);
+  return drupal_get_form('user_admin_access_form', $edit, 'access_rule', t('Add rule'));
 }
 
 /**
@@ -1643,13 +1659,11 @@ function user_admin_access_edit($aid = 0
   else {
     $edit = db_fetch_array(db_query('SELECT aid, type, status, mask FROM {access} WHERE aid = %d', $aid));
   }
-  $form = _user_admin_access_form($edit);
-  $form['submit'] = array('#type' => 'submit', '#value' => t('Save rule'));
-
-  return drupal_get_form('access_rule', $form);
+  return drupal_get_form('user_admin_access_form', $edit, 'access_edit', t('Save rule'));
 }
 
-function _user_admin_access_form($edit) {
+function user_admin_access_form($edit, $form_id, $submit) {
+  $form['#form_id'] = $form_id;
   $form['status'] = array(
     '#type' => 'radios',
     '#title' => t('Access type'),
@@ -1672,6 +1686,8 @@ function _user_admin_access_form($edit) 
     '#description' => '%: '. t('Matches any number of characters, even zero characters') .'.<br />_: '. t('Matches exactly one character.'),
     '#required' => TRUE,
   );
+  $form['submit'] = array('#type' => 'submit', '#value' => $submit);
+
   return $form;
 }
 
@@ -1783,7 +1799,7 @@ function user_admin_perm($str_rids = NUL
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
 
-  return drupal_get_form('user_admin_perm', $form);
+  return $form;
 }
 
 function theme_user_admin_perm($form) {
@@ -1887,11 +1903,13 @@ function user_admin_role() {
     $form['name'] = array('#type' => 'textfield', '#title' => t('Role name'), '#default_value' => $role->name, '#size' => 30, '#maxlength' => 64, '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'));
     $form['submit'] = array('#type' => 'submit', '#value' => t('Save role'));
     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete role'));
-    return drupal_get_form('user_admin_role', $form);
+    
+    return $form;
   }
   $form['name'] = array('#type' => 'textfield', '#size' => 32, '#maxlength' => 64);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Add role'));
-  return drupal_get_form('user_admin_new_role', $form);
+  $form['#form_id'] = 'user_admin_new_role';
+  return $form;
 }
 
 function theme_user_admin_new_role($form) {
@@ -1974,10 +1992,7 @@ function user_admin_account() {
   );
   $form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
 
-  // Call the form first, to allow for the form_values array to be populated.
-  $output .= drupal_get_form('user_admin_account', $form);
-
-  return $output;
+  return $form;
 }
 
 /**
@@ -2201,7 +2216,7 @@ function user_admin($callback_arg = '') 
       $output = user_register();
       break;
     default:
-      $output = user_admin_account();
+      $output = drupal_get_form('user_admin_account');
   }
   return $output;
 }
=== modified file 'modules/watchdog/watchdog.module'
--- modules/watchdog/watchdog.module	
+++ modules/watchdog/watchdog.module	
@@ -77,10 +77,7 @@ function watchdog_user($op, &$edit, &$us
   }
 }
 
-/**
- * Menu callback; displays a listing of log messages.
- */
-function watchdog_overview() {
+function watchdog_form_overview() {
   $icons = array(WATCHDOG_NOTICE  => '',
                  WATCHDOG_WARNING => theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')),
                  WATCHDOG_ERROR   => theme('image', 'misc/watchdog-error.png', t('error'), t('error')));
@@ -104,7 +101,13 @@ function watchdog_overview() {
   $form['#action'] = url('admin/logs');
 
   $form['submit'] = array('#type' => 'submit', '#value' =>t('Filter'));
-  $output = drupal_get_form('watchdog_form_overview', $form);
+  return $form;
+}
+/**
+ * Menu callback; displays a listing of log messages.
+ */
+function watchdog_overview() {
+  $output = drupal_get_form('watchdog_form_overview');
 
   $header = array(
     ' ',
=== modified file 'themes/engines/phptemplate/phptemplate.engine'
--- themes/engines/phptemplate/phptemplate.engine	
+++ themes/engines/phptemplate/phptemplate.engine	
@@ -204,7 +204,7 @@ function phptemplate_page($content) {
     'messages'            => theme('status_messages'),
     'mission'             => isset($mission) ? $mission : '',
     'primary_links'       => menu_primary_links(),
-    'search_box'          => (theme_get_setting('toggle_search') ? search_box() : ''),
+    'search_box'          => (theme_get_setting('toggle_search') ? drupal_get_form('search_box') : ''),
     'secondary_links'     => menu_secondary_links(),
     'sidebar_left'        => $sidebar_left,
     'sidebar_right'       => $sidebar_right,
