Index: trunk/FACT++/src/makeschedule.cc
===================================================================
--- trunk/FACT++/src/makeschedule.cc	(revision 18440)
+++ trunk/FACT++/src/makeschedule.cc	(revision 18441)
@@ -52,4 +52,32 @@
 #ifdef HAVE_ROOT
     cout <<
+        "First for each minute of the night a list is calculated of all "
+        "selected sources fullfiling all global and all source specific "
+        " constraints, e.g. on the zenith distance or the current.\n"
+        "\n"
+        "The remaining source list is sorted by the relative threshold, "
+        "while the threshold is weighted with a user defined source "
+        "specific panelty. The first source of the list is taken to "
+        "be observed.\n"
+        "\n"
+        "In a next step the first and last source of the resulting schedule "
+        "are evaluated. If their observation time is below 40', it is tried "
+        "to extend it to 40min. If this violates one of the criteria mentioned "
+        "above or gives an observation time for the neighboring source of "
+        "less than 40min, try to replace it by the neighboring source. "
+        "If this also does not fulfull the requirements, the original "
+        "schedule remains unchanged.\n"
+        "\n"
+        "Now a similar check is run for all intermediate sources. They are "
+        "checked (from the beginning to the end, one by one), if they have "
+        "an observation time of less than 40min. In this case, it is tried "
+        "to remove them. The observation of the two neighboring sources is "
+        "extended to their penelized point of equal relative threshold. "
+        "If this solution would not fullfil all criteria, no change is made.\n"
+        "\n"
+        "In a last step, all remaining sources with less than 5min "
+        "observation time are replaced with sleep and sleep after startup "
+        "or before shutdown are removed.\n"
+        "\n"
         "\n"
         "Examples:\n"
@@ -409,4 +437,69 @@
 }
 
+void RemoveMiniSources(vector<Source> &obs)
+{
+    for (size_t i=1; i<obs.size()-1; i++)
+    {
+        if (obs[i].duration()>=5./24/60)
+            continue;
+
+        if (obs[i-1].name=="SLEEP" && obs[i+1].name=="SLEEP")
+            continue;
+
+        cout << "Mini source [" << obs[i].name << "] detected < 5min... replaced by sleep." << endl;
+
+        if (obs[i-1].name=="SLEEP" && obs[i+1].name=="SLEEP")
+        {
+            obs[i-1].end = obs[i+2].begin;
+
+            obs.erase(obs.begin()+i+1);
+            obs.erase(obs.begin()+i);
+
+            i -= 2;
+
+            cout << "Combined two surrounding sleep into one" << endl;
+
+            continue;
+        }
+
+        if (obs[i-1].name=="SLEEP")
+        {
+            obs[i-1].end = obs[i+1].begin;
+            obs.erase(obs.begin()+i);
+            i--;
+
+            cout << "Extended previous sleep" << endl;
+
+            continue;
+        }
+
+        if (obs[i+1].name=="SLEEP")
+        {
+            obs[i+1].begin = obs[i-1].end;
+            obs.erase(obs.begin()+i);
+
+            cout << "Extended following sleep" << endl;
+
+            i--;
+            continue;
+        }
+    }
+}
+
+void CheckStartupAndShutdown(vector<Source> &obs)
+{
+    if (obs.front().name=="SLEEP")
+    {
+        obs.erase(obs.begin());
+        cout << "Detected sleep after startup... removed." << endl;
+    }
+
+    if (obs.back().name=="SLEEP")
+    {
+        obs.pop_back();
+        cout << "Detected sleep before shutdown... removed." << endl;
+    }
+}
+
 void Print(const vector<Source> &obs, double startup_offset)
 {
@@ -665,4 +758,7 @@
     while (RescheduleIntermediateSources(obs));
 
+    RemoveMiniSources(obs);
+    CheckStartupAndShutdown(obs);
+
     // ---------------------------------------------------------------------
 
