Index: trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java
===================================================================
--- trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java	(revision 83)
+++ trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java	(revision 85)
@@ -1465,7 +1465,10 @@
             boolean found = false;
             int indx = 0;
-            for (ScriptIncident i : script.incidents)
-            {
-                if (i == null)
+            // ALERT: Wacky logic follows
+            // Examine all the incidents contained in this script
+            for (ScriptIncident inci : script.incidents)
+            {
+                // If this spot in the list of incidents hasn't been assigned yet
+                if (inci == null)
                 {
                     found = true;
@@ -1473,5 +1476,6 @@
                 }
                 ++indx;
-                if (i.number == (Integer) addIncidentNumber.getValue())
+                // Does the new incident number match an existing one?
+                if (inci.number == (Integer) addIncidentNumber.getValue())
                 {
                     JOptionPane.showMessageDialog(this, "Incident number already in use.",
@@ -1481,4 +1485,5 @@
                 }
             }
+            // We examined all incidents and there wasn't an empty slot
             if (!found)
             {
@@ -1486,9 +1491,12 @@
                         "Unable to Create Incident", JOptionPane.ERROR_MESSAGE);
                 incidentFrame.setVisible(true);
+                // ALERT: exit from middle of method
                 return;
             }
 
-            script.incidents.remove(indx);
+            // We found a spot for the new incident
+            script.incidents.remove(indx); // remove the null incident placeholder
             SimulationScript.incidentColors[indx] = selectedColor;
+            // Add the new incident to the list
             script.incidents.add(indx,
                     new ScriptIncident(SimulationScript.incidentColors[indx],
