Index: trunk/bin/module_maker/form_template.cli.php
===================================================================
--- trunk/bin/module_maker/form_template.cli.php	(revision 19)
+++ trunk/bin/module_maker/form_template.cli.php	(revision 20)
@@ -65,5 +65,5 @@
         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
         <td valign="top">
-            <select name="$field" class="formselect">
+            <select name="$field" class="small">
             <\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field DESC'); \x3f>
             </select>
@@ -75,14 +75,14 @@
         
         // File upload.
-        if (preg_match('/file/i', $field)) {
-            $output[$field] = <<<E_O_F
-    <tr>
-        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
-        <td valign="top">
-            <input type="file" name="$field" value="<\x3fphp echo \$_FILES['$field']['name']; \x3f>" />
-            <\x3fphp if (getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
-            <div class="help"><\x3fphp printf(_("The current file <strong>%s</strong> will be overwritten if a new file is selected for upload."), \$frm['$field']) \x3f></div>
+        if (preg_match('/file|image/i', $field)) {
+            $output[$field] = <<<E_O_F
+    <tr>
+        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
+        <td valign="top">
+            <input type="file" name="$field" />
+            <\x3fphp if ('' != \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*') && getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
+            <div class="help"><\x3fphp printf(_("The current file <a href=\"%s/%2\$s\"><strong>%2\$s</strong></a> will be deleted if a new file is selected for upload."), '/_db_files/<##>', \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*')) \x3f></div>
             <\x3fphp } \x3f>
-            <div class="help"><\x3fphp printf(_("File to upload must have one of the following file-name extensions: %s."), join(', ', \$upload->valid_file_extensions)) \x3f></div>
+            <div class="help"><\x3fphp printf(_("File to upload must have one of the following file-name extensions: %s."), join(', ', \$upload->getParam('valid_file_extensions'))) \x3f></div>
         </td>
     </tr>
@@ -97,5 +97,5 @@
         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
         <td valign="top">
-            <input type="password" class="forminputtext" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>">
+            <input type="password" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" />
         </td>
     </tr>
@@ -138,5 +138,5 @@
         <td>&nbsp;</td>
         <td>
-            <input type="checkbox" name="$field" <\x3fphp frmChecked(!empty(\$frm['$field'])) \x3f>><label><\x3fphp echo _("$title"); \x3f></label>
+            <input type="checkbox" name="$field" <\x3fphp frmChecked(!empty(\$frm['$field'])) \x3f> /><label><\x3fphp echo _("$title"); \x3f></label>
         </td>
     </tr>
@@ -157,5 +157,5 @@
         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
         <td valign="top">
-            <textarea class="text" cols="75" rows="4" name="$field"><\x3fphp echo oTxt(\$frm['$field']); \x3f></textarea>
+            <textarea class="large" cols="75" rows="4" name="$field"><\x3fphp echo oTxt(\$frm['$field']); \x3f></textarea>
         </td>
     </tr>
@@ -196,5 +196,5 @@
         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
         <td valign="top">
-            <input type="text" class="text" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>">
+            <input type="text" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" />
         </td>
     </tr>
Index: trunk/bin/module_maker/list_template.cli.php
===================================================================
--- trunk/bin/module_maker/list_template.cli.php	(revision 19)
+++ trunk/bin/module_maker/list_template.cli.php	(revision 20)
@@ -112,5 +112,5 @@
     <br />
     
-    <input type="text" class="forminputtext" size="20" name="search_query" value="<\x3fphp echo getFormData('search_query'); \x3f>" title="<\x3fphp echo oTxt(_("Fields searched: <##>.")); \x3f>" />
+    <input type="text" class="small" size="20" name="search_query" value="<\x3fphp echo getFormData('search_query'); \x3f>" title="<\x3fphp echo oTxt(_("Fields searched: <##>.")); \x3f>" />
     <select name="filter_<##>">
         <\x3fphp // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', city, '&mdash;', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); \x3f>
Index: trunk/bin/module_maker/module.cli.php
===================================================================
--- trunk/bin/module_maker/module.cli.php	(revision 19)
+++ trunk/bin/module_maker/module.cli.php	(revision 20)
@@ -56,7 +56,7 @@
 
 // Names
-$module_title = ucwords($module_name_plural);
-$item_title = ucwords($module_name_singular);
-$module_name_upper = strtoupper($module_name_plural);
+$module_title = ucwords(str_replace('_', ' ', $module_name_plural));
+$item_title = ucwords(str_replace('_', ' ', $module_name_singular));
+$module_name_upper = strtoupper(str_replace('_', ' ', $module_name_plural));
 
 // Admin files
@@ -76,5 +76,12 @@
 // Only after we've defined essential files can we clean.
 if ('clean' == $op) {
-    cleanFiles();
+    echo "Beginning file cleanup\n";
+    trashFile("$admin_dir/$admin_script");
+    trashFile("$admin_tpl_dir/$admin_list_template");
+    trashFile("$admin_tpl_dir/$admin_form_template");
+    trashFile("$public_dir/$public_script");
+    trashFile("$public_tpl_dir/$public_list_template");
+    trashFile("$public_tpl_dir/$public_detail_template");    
+    echo "End file cleanup\n";
     die;
 }
@@ -140,5 +147,5 @@
 
 // Loop through columns
-$multipart_form_required = false;
+$upload_file_capability = false;
 $headers = array();
 $public_list_page_vars = array();
@@ -160,6 +167,6 @@
         
         // Our form will require type="multipart/form-data".
-        if (preg_match('/file/i', $field)) {
-            $multipart_form_required = true;
+        if (preg_match('/file|image/i', $field)) {
+            $upload_file_capability = true;
         }
         
@@ -184,5 +191,99 @@
 
 
-// -------------VARS-------------
+// Search-replace variables ----------------------------------
+
+// Admin script file upload replacement routines...
+
+$search['admin_form_tag_init'] = '/%ADMIN_FORM_TAG_INIT%/';
+$replace['admin_form_tag_init'] = "<form method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">";
+$search['admin_upload_include'] = '/%ADMIN_UPLOAD_INCLUDE%/';
+$replace['admin_upload_include'] = '';
+$search['admin_upload_config'] = '/%ADMIN_UPLOAD_CONFIG%/';
+$replace['admin_upload_config'] = '';
+$search['admin_upload_init'] = '/%ADMIN_UPLOAD_INIT%/';
+$replace['admin_upload_init'] = '';
+$search['admin_upload_del'] = '/%ADMIN_UPLOAD_DEL%/';
+$replace['admin_upload_del'] = '';
+$search['admin_upload_insert'] = '/%ADMIN_UPLOAD_INSERT%/';
+$replace['admin_upload_insert'] = '';
+$search['admin_upload_insert2'] = '/%ADMIN_UPLOAD_INSERT2%/';
+$replace['admin_upload_insert2'] = '';
+$search['admin_upload_update'] = '/%ADMIN_UPLOAD_UPDATE%/';
+$replace['admin_upload_update'] = '';
+
+if ($upload_file_capability) {
+    $replace['admin_form_tag_init'] = "<form enctype=\"multipart/form-data\" method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"<##>\" />";
+
+    $replace['admin_upload_include'] = "require_once 'codebase/lib/Upload.inc.php';\n";
+
+    $replace['admin_upload_config'] = <<<E_O_F
+
+// This module has file upload capability.
+\$upload = new Upload();
+\$upload->setParam(array(
+    'upload_path' => COMMON_BASE . '/html/_db_files/<##>',
+    'dest_file_perms' => 0666,
+    'allow_overwriting' => false,
+    'valid_file_extensions' => array('jpg', 'gif', 'png', 'jpeg'),
+));
+
+E_O_F;
+
+    $replace['admin_upload_init'] = <<<E_O_F
+
+// Copy uploaded image name into form data.
+\$_POST['<##>'] = isset(\$_FILES['<##>']) ? \$_FILES['<##>']['name'] : '';
+ 
+
+E_O_F;
+
+    $replace['admin_upload_del'] = <<<E_O_F
+
+    // Delete file.
+    if ('' != \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')) {
+        \$upload->deleteFile(\$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*'));
+    }
+E_O_F;
+
+    $replace['admin_upload_insert'] = <<<E_O_F
+
+	    // Upload file.
+        if (!\$new_files = \$upload->process('<##>')) {
+            // Upload failed. Reload form, displaying errors.
+            \$frm =& addRecordForm();
+            \$frm = array_merge(\$frm, getFormData());
+            \$nav->addPage(_("Add %ITEM_TITLE%"));
+            \$main_template = '%ADMIN_FORM_TEMPLATE%';
+            break;
+        }
+E_O_F;
+
+    $replace['admin_upload_insert2'] = <<<E_O_F
+
+        // Record inserted successfuly. Now we know the primary key, prepend to filename.
+        \$upload->moveFile(\$new_files[0]['name'], \$%PRIMARY_KEY% . '_' . \$new_files[0]['name']);
+E_O_F;
+
+    $replace['admin_upload_update'] = <<<E_O_F
+
+        // Upload new file.
+        if (getFormData('<##>')) {
+            if (\$upload->process('<##>',  getFormData('%PRIMARY_KEY%') . '_' . getFormData('<##>'))) {
+                // Upload success. Delete old file.
+                if ('' != \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')) {
+                    \$upload->deleteFile(\$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*'));
+                }
+            } else {
+                // Upload failed. Reload form, displaying errors.
+                \$frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
+                \$frm = array_merge(\$frm, getFormData());
+                \$nav->addPage(_("Edit %ITEM_TITLE%"));
+                \$main_template = '%ADMIN_FORM_TEMPLATE%';
+                break;
+            }            
+        }
+E_O_F;
+} // End if.
+
 
 // Simple...
@@ -242,10 +343,4 @@
 $replace['search_fields'] = join(", ", $headers);
 
-$search['admin_form_tag_init'] = '/%ADMIN_FORM_TAG_INIT%/';
-if ($multipart_form_required) {
-    $replace['admin_form_tag_init'] = "<form enctype=\"multipart/form-data\" method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"12000000\">";
-} else {
-    $replace['admin_form_tag_init'] = "<form method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">";
-}
 
 
@@ -419,23 +514,16 @@
  *****************************************************************************/
 
-/**
- * Removes existing modules files. Danger!
- */
-function cleanFiles()
+function trashFile($file_path_name)
 {
     global $user_trash_folder;
-    global $admin_dir;
-    global $admin_script;
-    global $admin_tpl_dir;
-    global $admin_list_template;
-    global $admin_form_template;
-    global $public_dir;
-    global $public_script;
-    global $public_tpl_dir;
-    global $public_detail_template;
-    global $public_list_template;
+    static $file_prefix;
     
-    echo "Beginning file cleanup\n";
-
+    if (!isset($file_prefix)) {
+        $file_prefix = time();
+    } else {
+        $file_prefix++;
+    }
+    
+    // Make user trash folder.
     if (!dir($user_trash_folder)) {
         mkdir($user_trash_folder);
@@ -447,47 +535,11 @@
     }
 
-    if (file_exists("$admin_dir/$admin_script")) {
-        rename("$admin_dir/$admin_script", "$user_trash_folder/$admin_script" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$admin_dir/$admin_script");
+    // Move file to trash.
+    if (file_exists($file_path_name)) {
+        rename($file_path_name, sprintf('%s/%s_%s', $user_trash_folder, $file_prefix, basename($file_path_name)));
+        printf("Moved to trash: %s -> %s\n", $file_path_name, sprintf('%s/%s_%s', $user_trash_folder, $file_prefix, basename($file_path_name)));
     } else {
-        printf("File not found: %s\n", "$admin_dir/$admin_script");
-    }
-
-    if (file_exists("$admin_tpl_dir/$admin_list_template")) {
-        rename("$admin_tpl_dir/$admin_list_template", "$user_trash_folder/$admin_list_template" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$admin_tpl_dir/$admin_list_template");
-    } else {
-        printf("File not found: %s\n", "$admin_tpl_dir/$admin_list_template");
-    }
-
-    if (file_exists("$admin_tpl_dir/$admin_form_template")) {
-        rename("$admin_tpl_dir/$admin_form_template", "$user_trash_folder/$admin_form_template" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$admin_tpl_dir/$admin_form_template");
-    } else {
-        printf("File not found: %s\n", "$admin_tpl_dir/$admin_form_template");
-    }
-
-    if (file_exists("$public_dir/$public_script")) {
-        rename("$public_dir/$public_script", "$user_trash_folder/$public_script" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$public_dir/$public_script");
-    } else {
-        printf("File not found: %s\n", "$public_dir/$public_script");
-    }
-
-    if (file_exists("$public_tpl_dir/$public_list_template")) {
-        rename("$public_tpl_dir/$public_list_template", "$user_trash_folder/$public_list_template" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$public_tpl_dir/$public_list_template");
-    } else {
-        printf("File not found: %s\n", "$public_tpl_dir/$public_list_template");
-    }
-
-    if (file_exists("$public_tpl_dir/$public_detail_template")) {
-        rename("$public_tpl_dir/$public_detail_template", "$user_trash_folder/$public_detail_template" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$public_tpl_dir/$public_detail_template");
-    } else {
-        printf("File not found: %s\n", "$public_tpl_dir/$public_detail_template");
-    }
-    
-    echo "End file cleanup\n";
+        printf("File not found: %s\n", $file_path_name);
+    }
 }
 
Index: trunk/bin/module_maker/skel/adm_form.ihtml
===================================================================
--- trunk/bin/module_maker/skel/adm_form.ihtml	(revision 19)
+++ trunk/bin/module_maker/skel/adm_form.ihtml	(revision 20)
@@ -3,6 +3,6 @@
 %ADMIN_FORM_TAG_INIT%
 <?php App::printHiddenSession(); ?>
-<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>">
-<input type="hidden" name="%PRIMARY_KEY%" value="<?php echo $frm['%PRIMARY_KEY%']; ?>">
+<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
+<input type="hidden" name="%PRIMARY_KEY%" value="<?php echo $frm['%PRIMARY_KEY%']; ?>" />
 
 <table>
Index: trunk/bin/module_maker/skel/adm_list.ihtml
===================================================================
--- trunk/bin/module_maker/skel/adm_list.ihtml	(revision 19)
+++ trunk/bin/module_maker/skel/adm_list.ihtml	(revision 20)
@@ -1,5 +1,5 @@
 
 <?php $fv->printErrorMessages(); ?>
-<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
+<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
 <?php App::printHiddenSession(false); ?>
 
@@ -8,5 +8,5 @@
     <br />
     
-    <input type="text" class="forminputtext" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: %SEARCH_FIELDS%.")); ?>" />
+    <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: <##> %SEARCH_FIELDS%.")); ?>" />
     <select name="filter_<##>">
         <?php // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', city, '&mdash;', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); ?>
@@ -14,7 +14,9 @@
     <input type="submit" name="list" value="<?php echo _("Search"); ?>" />
 </div>
+</form>
 
+<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
+<?php App::printHiddenSession(); ?>
 <?php include 'list_info.ihtml'; ?>
-
 <table class="list">
     <tr>
@@ -26,8 +28,8 @@
     <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
     <tr>
-        <td class="padleft nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
-        <td class="padleft nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
+        <td class="padleft nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
+        <td class="padleft nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
 %ADM_LIST_ROWS%
-        <td class="padleft nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['______RECORD_NAME______'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
+        <td class="padleft nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['<##>'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
     </tr>
     <?php } ?>
Index: trunk/bin/module_maker/skel/admin.php
===================================================================
--- trunk/bin/module_maker/skel/admin.php	(revision 19)
+++ trunk/bin/module_maker/skel/admin.php	(revision 20)
@@ -21,5 +21,5 @@
 require_once 'codebase/lib/RecordLock.inc.php';
 require_once 'codebase/lib/RecordVersion.inc.php';
-
+%ADMIN_UPLOAD_INCLUDE%
 
 /******************************************************************************
@@ -40,11 +40,15 @@
 $page->setPageNumber(getFormData('page_number'));
 
+// Search limiters retain their values between page requests.
+App::carryQuery('search_query');
+App::carryQuery('filter_<##>');
+%ADMIN_UPLOAD_CONFIG%
 /******************************************************************************
  * MAIN
  *****************************************************************************/
- 
+ %ADMIN_UPLOAD_INIT%
 // We may want to use the add/edit interface from another script, so this
 // allows us to remember which page we came from so we can go back there.
-if (getFormData('boomerang', false)) {
+if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     App::setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
 }
@@ -76,5 +80,5 @@
 case 'del' :
 //     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_DELETE);
-    deleteRecord(getFormData('%PRIMARY_KEY%'));
+    deleteRecord(getFormData('%PRIMARY_KEY%'));%ADMIN_UPLOAD_DEL%
     if (App::validBoomerangURL('%NAME_PLURAL%')) {
         // Display boomerang page.
@@ -96,6 +100,6 @@
         $nav->addPage(_("Add %ITEM_TITLE%"));
         $main_template = '%ADMIN_FORM_TEMPLATE%';
-    } else {
-        $%PRIMARY_KEY% = insertRecord(getFormData());
+    } else {%ADMIN_UPLOAD_INSERT%
+        $%PRIMARY_KEY% = insertRecord(getFormData());%ADMIN_UPLOAD_INSERT2%
         if (getFormdata('repeat', false)) {
             // Display function again.
@@ -134,5 +138,5 @@
         $nav->addPage(_("Edit %ITEM_TITLE%"));
         $main_template = '%ADMIN_FORM_TEMPLATE%';
-    } else {
+    } else {%ADMIN_UPLOAD_UPDATE%
         updateRecord(getFormData());
         if (getFormdata('repeat', false)) {
@@ -277,5 +281,5 @@
 
     // Create version.
-    $version = new RecordVersion($GLOBALS['auth']);
+    $version = RecordVersion::getInstance($GLOBALS['auth']);
     $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']);
     
@@ -300,5 +304,5 @@
         
         // Create version.
-        $version = new RecordVersion($GLOBALS['auth']);
+        $version = RecordVersion::getInstance($GLOBALS['auth']);
         $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']);
     
@@ -403,6 +407,6 @@
     foreach ($ranks as $id => $new_rank) {
         if ('' == trim($new_rank) || !is_numeric($new_rank) || $new_rank > 2147483646) {
-            // Unspecified entries recieve a sort order of 1000.
-            $new_rank = 1000;
+            // Unspecified entries receive a sort order of 10000.
+            $new_rank = 10000;
             $unspecified_counter++; 
         }
@@ -416,5 +420,5 @@
     App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
     if ($unspecified_counter > 0) {
-        App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 1000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
+        App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
     }
 }
