diff --git a/flot.module b/flot.module
index 5e6f782..b671ea2 100644
--- a/flot.module
+++ b/flot.module
@@ -81,6 +81,7 @@ function template_preprocess_flot_graph(&$variables) {
     }
   }
 
+  $options->legend = isset($options->legend) ? $options->legend : new stdClass();
   if (isset($variables['legend']) && $variables['legend']) {
     if (!isset($options->legend)) {
       // Default position bottom
@@ -148,9 +149,17 @@ function template_preprocess_flot_graph(&$variables) {
   if($zoom && (!isset($options->series->pie->show) || $options->series->pie->show == FALSE)) {
     $zoom_options = clone $options;
     $zoom_data = $data;
+    if(!isset($zoom_options->series)){
+        $zoom_options->series  = new stdClass();
+        $zoom_options->series->points  = new stdClass();
+        $zoom_options->series->lines  = new stdClass();
+    }
     $zoom_options->series->points->show = FALSE;
     $zoom_options->series->lines->lineWidth = 1;
     $zoom_options->series->shadowSize = 0;
+    if(!isset($zoom_options->grid)){
+        $zoom_options->grid = new stdClass();
+    }
     $zoom_options->grid->hoverable = FALSE;
     $zoom_options->selection['mode'] = 'x';
     $zoom_options->legend->show = FALSE;
@@ -165,6 +174,9 @@ function template_preprocess_flot_graph(&$variables) {
     }
     foreach ($zoom_data as &$zdata) {
       if (isset($zdata->lines) || isset($zdata->bars) || isset($zdata->pie)) {
+        if(!isset($zdata->points)){
+            $zdata->points = new stdClass();
+        }
         $zdata->points->show = FALSE;
       }
     }
@@ -419,6 +431,10 @@ class flotPie extends flot {
   function __construct($settings = NULL) {
     $this->show = TRUE;
     $this->radius = 1;
+    if(!isset($this->label)){
+        $this->label = new stdClass();
+        $this->label->background = new stdClass();
+    }
     $this->label->show = TRUE;
     $this->label->radius = 2/3;
     $this->label->threshold = 0.1;
@@ -469,9 +485,11 @@ class flotStylePie extends flotStyle {
     parent::__construct();
     $this->series->pie->show = TRUE;
     $this->series->pie->radius = 1;
+    $this->series->pie->label = new stdClass();
     $this->series->pie->label->show = TRUE;
     $this->series->pie->label->radius = 2/3;
     $this->series->pie->label->threshold = 0.1;
+    $this->series->pie->label->background = new stdClass();
     $this->series->pie->label->background->opacity = 1;
   }
 
