diff --git a/admin/rehash.php b/admin/rehash.php
--- a/admin/rehash.php
+++ b/admin/rehash.php
@@ -92,6 +92,17 @@ function school_list()
 
 /**
  * \brief
+ *   Compare the two schools by their names.
+ *
+ * \see strcmp()
+ */
+function school_cmp($school_a, $school_b)
+{
+  return strcmp($school_a['name'], $school_b['name']);
+}
+
+/**
+ * \brief
  *   Write out the cache file which remembers the list of available
  *   schools.
  *
@@ -133,6 +144,7 @@ function school_cache($schools)
 	  $domain_cache_ptr[$domain_part] = $school['id'];
 	}
     }
+  uasort($list_cache, 'school_cmp');
 
   $cache = array('list' => $list_cache, 'domains' => $domain_cache);
 
diff --git a/class.class.php b/class.class.php
--- a/class.class.php
+++ b/class.class.php
@@ -73,10 +73,10 @@ class Classes
   {
     $n = "\n";
     $out = '
' . $n
-      . '  | getName()) . '"/> | ' . $n
+      . '   | ' . $n
       . '   | ' . $n
-      . '   | ' . $n
-      . '   | ' . $n
+      . '   | ' . $n
+      . '   | ' . $n
       . "
\n";
 
     foreach ($this->sections as $key => $section)
diff --git a/class.schedule.php b/class.schedule.php
--- a/class.schedule.php
+++ b/class.schedule.php
@@ -290,7 +290,7 @@ class Schedule
 	"\n"; */
       $headcode = array('outputStyle',  'jQuery', 'jQueryUI', 'uiTabsKeyboard');
     }
-    $outputPage = new page($this->getName(), $headcode);
+    $outputPage = new Page(htmlentities($this->getName()), $headcode);
 
 
 
@@ -377,11 +377,11 @@ class Schedule
 			      {
 				if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
 				  {
-				    $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				    $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				    $M = $j;
 				    $filled = true;
 				  } else {
-				  $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				  $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				  $filled = true;
 				}
 			      }
@@ -420,11 +420,11 @@ class Schedule
 			      {
 				if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
 				  {
-				    $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				    $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				    $Tu = $j;
 				    $filled = true;
 				  } else {
-				  $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				  $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				  $filled = true;
 				}
 			      }
@@ -463,11 +463,11 @@ class Schedule
 			      {
 				if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
 				  {
-				    $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				    $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				    $W = $j;
 				    $filled = true;
 				  } else {
-				  $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				  $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				  $filled = true;
 				}
 			      }
@@ -506,11 +506,11 @@ class Schedule
 			      {
 				if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
 				  {
-				    $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				    $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				    $Th = $j;
 				    $filled = true;
 				  } else {
-				  $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				  $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				  $filled = true;
 				}
 			      }
@@ -549,11 +549,11 @@ class Schedule
 			      {
 				if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1])
 				  {
-				    $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				    $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				    $F = $j;
 				    $filled = true;
 				  } else {
-				  $table .= "\n\t\t" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . " | ";
+				  $table .= "\n\t\t" . htmlentities($this->classStorage[$j]->getName()) . " " . htmlentities( $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() ) . " | ";
 				  $filled = true;
 				}
 			      }
diff --git a/class.section.php b/class.section.php
--- a/class.section.php
+++ b/class.section.php
@@ -172,7 +172,7 @@ class Section
 	$out .= '  ' . $n
 	. '    ' . $n
+	. '           value="' . htmlentities($this->letter) . '" />' . $n
 	. "   | \n";
       break;
       }
@@ -242,7 +242,7 @@ class Section
 	  . "  \n";
       }
 
-    $out .= '   | ' . $n;
+    $out .= '   | ' . $n;
     $out .= '   | ' . $n;
 
     $out .= "\n";
diff --git a/inc/class.page.php b/inc/class.page.php
--- a/inc/class.page.php
+++ b/inc/class.page.php
@@ -40,6 +40,10 @@ class page
   /* the current school. See get_school(). */
   private $school;
 
+  /**
+   * \param $ntitle
+   *   Must be a valid HTML string (i.e., escaped with htmlentities()).
+   */
   public function __construct($ntitle, $nscripts = array(), $immediate = TRUE)
   {
     global $ga_trackers;
@@ -91,14 +95,14 @@ class page
 	 . "  \n";
      }
 
-   self::session_start();
+    self::session_start();
+    /* everything that needs sessions started to work: */
+
+    $this->school = school_load_guess();
+
     if($immediate
        && $ntitle != "NOHEAD")
       $this->head();
-
-    /* everything that needs sessions started to work: */
-
-    $this->school = school_load_guess();
  }
 
   /**
@@ -171,7 +175,8 @@ class page
 		Submit Feedback
             
             
          
diff --git a/input.php b/input.php
--- a/input.php
+++ b/input.php
@@ -51,16 +51,19 @@ if ($school && (!empty($_REQUEST['school
 if (!empty($_REQUEST['selectschool'])
     || $school['id'] == 'default' && !isset($_SESSION['school_chosen']))
   {
+    $next_page = 'input.php';
+    if (isset($_GET['s']))
+      $next_page .= '?s=' . (int)$_GET['s'];
 ?>
 School Selection
 
   Choose the school you attend from the list below. If you cannot
   find your school, you may proceed using
-  the generic
+  the generic
   settings.
 
 showSchools('input.php');
+    $inputPage->showSchools($next_page);
     $inputPage->foot();
     exit;
   }
@@ -76,7 +79,7 @@ if (!empty($_REQUEST['selectschool'])
 
 
 getName()) . '"'; /*"*/ ?>
+getName()) . '"'; /*"*/ ?>
 />