diff --git a/esi.inc b/esi.inc
index 7d40e9b..665608e 100644
--- a/esi.inc
+++ b/esi.inc
@@ -69,8 +69,25 @@ function _esi__get_block($theme, $region, $module, $delta) {
   $theme_key = $theme;
   init_theme();
 
-  $blocks = block_list($region);
-  return $blocks["{$module}_{$delta}"];
+  $block = db_fetch_object(db_query("SELECT * FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme));
+  $block->context = $region;
+  $block->status = 1;
+  $array = module_invoke($block->module, 'block', 'view', $block->delta);
+  if (isset($array) && is_array($array)) {
+    foreach ($array as $k => $v) {
+      $block->$k = $v;
+    }
+  }
+
+  if (!empty($block->title)) {
+    // Check plain here to allow module generated titles to keep any markup.
+    $block->subject = $block->title == '<none>' ? '' : check_plain($block->title);
+  }
+  if (!isset($block->subject)) {
+    $block->subject = '';
+  }
+
+  return $block;
 }
 
 /**
diff --git a/esi.module b/esi.module
index 7d381cc..118cb6b 100755
--- a/esi.module
+++ b/esi.module
@@ -33,17 +33,17 @@ function esi_theme() {
  * Override theme('blocks') to apply our ESI handler.
  */
 function esi_theme_registry_alter(&$theme_registry) {
-  // override the default theme function for theme('blocks').
-  $path = drupal_get_path('module', 'esi');
-  $theme_registry['blocks']['function'] = 'esi__theme_blocks';
-  $theme_registry['blocks']['file'] = 'esi.theme.inc';
-  $theme_registry['blocks']['include files'] = array( "./{$path}/esi.theme.inc");
-  $theme_registry['blocks']['theme path']  = $path;
-  $theme_registry['blocks']['theme paths'] = array($path);
+  if (!module_exists('context')) {
+    // override the default theme function for theme('blocks').
+    $path = drupal_get_path('module', 'esi');
+    $theme_registry['blocks']['function'] = 'esi__theme_blocks';
+    $theme_registry['blocks']['file'] = 'esi.theme.inc';
+    $theme_registry['blocks']['include files'] = array( "./{$path}/esi.theme.inc");
+    $theme_registry['blocks']['theme path']  = $path;
+    $theme_registry['blocks']['theme paths'] = array($path);
+  }
 }
 
-
-
 /**
  * Implementation of hook_menu().
  *   Define a menu-handler.
@@ -250,3 +250,37 @@ function esi__block_handler($bid, $page = NULL) {
   echo $output;
   return NULL;
 }
+
+
+/**
+ * Implements hook_context_plugins to define our custom block context plugin
+ *
+ * @return array
+ */
+function esi_context_plugins() {
+  $plugins = array();
+  $plugins['context_reaction_esi_block'] = array(
+    'handler' => array(
+      'path' => drupal_get_path('module', 'esi') .'/plugins',
+      'file' => 'context_reaction_esi_block.inc',
+      'class' => 'context_reaction_esi_block',
+      'parent' => 'context_reaction_block',
+  ),
+  );
+
+  return $plugins;
+}
+
+/**
+ * Implements hook_context_registry_alter to use our custom block context plugin
+ * to output ESI tags instead of the block
+ *
+ * @param $registry array
+ */
+function esi_context_registry_alter(&$registry) {
+  if (isset($registry['reactions']['block'])) {
+    $registry['reactions']['block']['plugin'] = 'context_reaction_esi_block';
+  }
+}
+
+
diff --git a/plugins/context_reaction_esi_block.inc b/plugins/context_reaction_esi_block.inc
new file mode 100644
index 0000000..3c675a5
--- /dev/null
+++ b/plugins/context_reaction_esi_block.inc
@@ -0,0 +1,36 @@
+<?php
+class context_reaction_esi_block extends context_reaction_block {
+  protected function build_block($block, $reset = FALSE) {
+  require_once(dirname(__FILE__)  . '/../esi.inc');
+    $esi_config = _esi__block_settings($block->module, $block->delta);
+
+    if ($esi_config->enabled) {
+      $block->content = theme('esi_tag', $block);
+    }
+    else {
+      $array = module_invoke($block->module, 'block', 'view', $block->delta);
+      if (isset($array) && is_array($array)) {
+        foreach ($array as $k => $v) {
+          $block->$k = $v;
+        }
+      }
+    }
+
+    if (!empty($block->content)) {
+      // Only query for custom block title if block core compatibility is enabled.
+      if (!variable_get('context_reaction_block_disable_core', FALSE)) {
+        global $user, $theme_key;
+        $block->title = db_result(db_query("SELECT title FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block->module, $block->delta, $theme_key));
+      }
+      // Override default block title if a custom display title is present.
+      if (!empty($block->title)) {
+        // Check plain here to allow module generated titles to keep any markup.
+        $block->subject = $block->title == '<none>' ? '' : check_plain($block->title);
+      }
+      if (!isset($block->subject)) {
+        $block->subject = '';
+      }
+    }
+    return $block;
+  }
+}
