diff --git a/flot.module b/flot.module
index 5e6f782..347aabd 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
@@ -469,9 +470,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;
   }
 
