diff --git a/src/helma/util/CronJob.java b/src/helma/util/CronJob.java
index 87b83f98..e381eebe 100644
--- a/src/helma/util/CronJob.java
+++ b/src/helma/util/CronJob.java
@@ -193,6 +193,8 @@ public class CronJob {
             StringTokenizer st = new StringTokenizer (key.trim(), ".");
             st.nextElement ();
             String jobName = st.nextToken ();
+             if (jobName == null || jobName.equals(""))
+                continue;
             String jobSpec = st.nextToken ();
             if (jobSpec==null || jobSpec.equals("")) // might happen with cron.testname. = XXX
                continue;
@@ -222,7 +224,16 @@ public class CronJob {
          } catch (NoSuchElementException nsee) {
          }
       }
-      List jobVec = new ArrayList (jobs.values ());
+      Iterator it = jobs.values().iterator();
+      while (it.hasNext()) {
+          CronJob job = (CronJob) it.next();
+          if (job.getFunction() == null) {
+              System.err.println("DROPPING CRON JOB " + job);
+              it.remove();
+          }
+      }
+      List jobVec = new ArrayList (jobs.values());
+      System.err.println("GOT CRON JOB LIST: " + jobVec);
       return sort (jobVec);
    }
 
@@ -412,7 +423,13 @@ public class CronJob {
     public static long millisToNextFullMinute () {
         long now = System.currentTimeMillis();
         long millisAfterMinute = (now % 60000);
-        return (60000 - millisAfterMinute);
+        // We return the interval to one second past the next full minute
+        // to avoid the case where the scheduler wakes up slightly before the minute
+        // and finishes so fast that the next call to this method returns the
+        // interval to the same minute instead of the next one. This happened 
+        // sometimes with the old code and caused the scheduler to run twice in
+        // immediate succession.
+        return (61000 - millisAfterMinute);
     }
 
   /**