diff --git a/block_styles.module b/block_styles.module
index d8f8926..c463681 100644
--- a/block_styles.module
+++ b/block_styles.module
@@ -13,9 +13,11 @@
  * Implements hook_theme_suggestions_HOOK_alter() for block templates.
  */
 function block_styles_theme_suggestions_block_alter(array &$suggestions, array $variables) {
-  $style = _block_styles_get_style($variables['elements']['#id']);
-  if ( $style['theme'] ) {
-    $suggestions[] = $style['theme'];
+  if (!empty($variables['elements']['#id'])) {
+    $style = _block_styles_get_style($variables['elements']['#id']);
+    if ($style['theme']) {
+      $suggestions[] = $style['theme'];
+    }
   }
 }
 
@@ -23,15 +25,16 @@ function block_styles_theme_suggestions_block_alter(array &$suggestions, array $
  * Implements hook_preprocess_block() for blocks.
  */
 function block_styles_preprocess_block(&$variables) {
-  $style = _block_styles_get_style($variables['elements']['#id']);
-  if ( $style['classes'] ) {
-    $variables['attributes']['class'][] = $style['classes'];
-  }
-  if ( $style['text'] ) {
-    $variables['configuration']['button_text'] = t($style['text']);
-  } 
-  else {
-    $variables['configuration']['button_text'] = $variables['configuration']['label'];
+  if (!empty($variables['elements']['#id'])) {
+    $style = _block_styles_get_style($variables['elements']['#id']);
+    if ($style['classes']) {
+      $variables['attributes']['class'][] = $style['classes'];
+    }
+    if ($style['text']) {
+      $variables['configuration']['button_text'] = t($style['text']);
+    } else {
+      $variables['configuration']['button_text'] = $variables['configuration']['label'];
+    }
   }
 }
 
