diff --git a/theme/theme.inc b/theme/theme.inc
index 19e01a3..957b5c5 100644
--- a/theme/theme.inc
+++ b/theme/theme.inc
@@ -293,6 +293,7 @@ function template_preprocess_calendar_day(&$vars) {
   
   // Move all_day items into the right columns and render them.
   $grouped_items = array();
+  if (!empty($rows['all_day'])) {
   foreach ($rows['all_day'] as $item) {
     if (isset($item->{$grouping_field})) {
       $column = $item->{$grouping_field};        
@@ -308,6 +309,7 @@ function template_preprocess_calendar_day(&$vars) {
     $grouped_items[$column][] = theme($theme, $item, $view);
     $item_count++;
   }
+  }
   $vars['rows']['all_day'] = $grouped_items;
   
   // Moved timed items into the right columns and render them.
@@ -318,6 +320,7 @@ function template_preprocess_calendar_day(&$vars) {
   $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time;
   
   $grouped_items = array();
+  if (!empty($rows['items'])) {
   foreach ($rows['items'] as $time => $items) {
     foreach ($items as $item) {
       if (isset($item->{$grouping_field})) {
@@ -345,6 +348,7 @@ function template_preprocess_calendar_day(&$vars) {
       $by_hour_count++;
     }
   }
+  }
   
   // Finish out the day's time values if we want to see empty times.
   if (!empty($show_empty_times)) {
@@ -421,6 +425,7 @@ function template_preprocess_calendar_week(&$vars) {
   $end_start_time = '23:59:59';
   
   $grouped_items = array();
+  if (is_array($rows[0])) {
   $vars['rows'] = $rows[0];
   foreach ($rows[0] as $weekno => $row) {
     $vars['rows'][$weekno] = $row['data'];
@@ -471,6 +476,10 @@ function template_preprocess_calendar_week(&$vars) {
       }
     }
   }
+  }
+  else {
+    $vars['rows'] = array();
+  }
   ksort($grouped_items);
   
   // Do the headers last, once we know what the actual values are.
