diff --git includes/view.inc includes/view.inc
index d6cbee8..237c6da 100644
--- includes/view.inc
+++ includes/view.inc
@@ -541,7 +541,7 @@ class view extends views_db_object {
       $class = get_class($this->query);
       if ($class && $class != 'stdClass') {
         // return if query is already initialized.
-        return;
+        return TRUE;
       }
     }
 
@@ -552,11 +552,19 @@ class view extends views_db_object {
       $this->base_database = $views_data['table']['base']['database'];
     }
 
+    // Load the options.
+    $query_options = $this->display_handler->get_option('query');
+
     // Create and initialize the query object.
     $plugin = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
     $this->query = views_get_plugin('query', $plugin);
 
-    $this->query->init($this->base_table, $this->base_field);
+    if (empty($this->query)) {
+      return FALSE;
+    }
+
+    $this->query->init($this->base_table, $this->base_field, $query_options['options']);
+    return TRUE;
   }
 
   /**
@@ -1083,9 +1091,7 @@ class view extends views_db_object {
    */
   function build_title() {
     $this->init_display();
-    if (empty($this->built)) {
-      $this->init_query();
-    }
+
     $this->init_handlers();
 
     $this->_build_arguments();
diff --git plugins/views_plugin_display.inc plugins/views_plugin_display.inc
index 35a6653..a14d055 100644
--- plugins/views_plugin_display.inc
+++ plugins/views_plugin_display.inc
@@ -257,6 +257,7 @@ class views_plugin_display extends views_plugin {
       'title' => array('title'),
       'css_class' => array('css_class'),
       'use_ajax' => array('use_ajax'),
+      'query' => array('query'),
       'items_per_page' => array('items_per_page', 'offset', 'use_pager', 'pager_element'),
       'pager' => array('pager'),
       'use_more' => array('use_more', 'use_more_always', 'use_more_text'),
@@ -321,6 +322,7 @@ class views_plugin_display extends views_plugin {
         'default' => array(
           'access' => TRUE,
           'cache' => TRUE,
+          'query' => TRUE,
           'title' => TRUE,
           'css_class' => TRUE,
 
@@ -416,6 +418,12 @@ class views_plugin_display extends views_plugin {
           'type' => array('default' => 'none', 'export' => 'export_plugin'),
          ),
       ),
+      'query' => array(
+        'contains' => array(
+          'type' => array('default' => 'views_query', 'export' => 'export_plugin'),
+          'options' => array('default' => array(), 'export' => FALSE),
+         ),
+      ),
       // Note that exposed_form plugin has options in a separate array,
       // while access and cache do not. access and cache are legacy and
       // that pattern should not be repeated, but it is left as is to
@@ -625,6 +633,9 @@ class views_plugin_display extends views_plugin {
           }
 
           break;
+        case 'query':
+          $views_data = views_fetch_data($this->view->base_table);
+          $name = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
         default:
           $option_name = $type;
           $options = $this->get_option($type);
@@ -638,13 +649,17 @@ class views_plugin_display extends views_plugin {
             $options = $options['options'];
           }
       }
-
       $plugin = views_get_plugin($type, $name);
+
       if (!$plugin) {
         return;
       }
-
-      $plugin->init($this->view, $this->display, $options);
+      if ($type != 'query') {
+        $plugin->init($this->view, $this->display, $options);
+      }
+      else {
+        $plugin->init($this->view->base_table, $this->view->base_field, $options);
+      }
       $cache[$type][$name] = $plugin;
     }
 
@@ -927,6 +942,13 @@ class views_plugin_display extends views_plugin {
       );
     }
 
+    $options['query'] = array(
+      'category' => 'advanced',
+      'title' => t('Query settings'),
+      'value' => t('Settings'),
+      'desc' => t('Allow to set some advanced settings for the query plugin'),
+    );
+
     $access_plugin = $this->get_plugin('access');
     if (!$access_plugin) {
       // default to the no access control plugin.
@@ -1232,6 +1254,35 @@ class views_plugin_display extends views_plugin {
           $plugin->options_form($form['cache_options'], $form_state);
         }
         break;
+      case 'query':
+        $query_options = $this->get_option('query');
+        $plugin_name = $query_options['type'];
+
+        $form['#title'] .= t('Query options');
+        $this->view->init_query();
+        if ($this->view->query) {
+          if (isset($this->view->query->definition['help topic'])) {
+            $form['#help_topic'] = $this->view->query->definition['help topic'];
+          }
+
+          if (isset($this->view->query->definition['module'])) {
+            $form['#help_module'] = $this->view->query->definition['module'];
+          }
+
+          $form['query'] = array(
+            '#tree' => TRUE,
+            'type' => array(
+              '#type' => 'value',
+              '#value' => $plugin_name,
+            ),
+            'options' => array(
+              '#tree' => TRUE,
+            ),
+          );
+          
+          $this->view->query->options_form($form['query']['options'], $form_state);
+        }
+        break;
       case 'style_plugin':
         $form['#title'] .= t('How should this view be styled');
         $form['#help_topic'] = 'style';
@@ -1693,6 +1744,11 @@ class views_plugin_display extends views_plugin {
           $plugin->options_validate($form['access_options'], $form_state);
         }
         break;
+      case 'query':
+        if ($this->view->query) {
+          $this->view->query->options_validate($form['query'], $form_state);
+        }
+        break;
       case 'cache_options':
         $plugin = $this->get_plugin('cache');
         if ($plugin) {
@@ -1777,6 +1833,14 @@ class views_plugin_display extends views_plugin {
           $this->set_option('cache', $form_state['values'][$section]);
         }
         break;
+      case 'query':
+        $plugin = $this->get_plugin('query');
+        if ($plugin) {
+          $plugin->options_submit($form['query']['options'], $form_state);
+          $this->set_option('query', $form_state['values'][$section]);
+        }
+        break;
+
       case 'title':
       case 'css_class':
       case 'link_display':
diff --git plugins/views_plugin_display_block.inc plugins/views_plugin_display_block.inc
index 2de4277..b528b15 100644
--- plugins/views_plugin_display_block.inc
+++ plugins/views_plugin_display_block.inc
@@ -50,6 +50,7 @@ class views_plugin_display_block extends views_plugin_display {
     // display, and arguments should be set on the view.
     $info['content'] = $this->view->render();
     $info['subject'] = filter_xss_admin($this->view->get_title());
+    $info['view'] = $this->view;
     if (!empty($this->view->result) || $this->get_option('empty') || !empty($this->view->style_plugin->definition['even empty'])) {
       return $info;
     }
diff --git plugins/views_plugin_query.inc plugins/views_plugin_query.inc
index 2b85815..b0ff60a 100644
--- plugins/views_plugin_query.inc
+++ plugins/views_plugin_query.inc
@@ -17,7 +17,9 @@ class views_plugin_query extends views_plugin {
   /**
    * Constructor; Create the basic query object and fill with default values.
    */
-  function init($base_table, $base_field) {  }
+  function init($base_table, $base_field, $options) {
+    $this->options = $options;
+  }
 
   /**
    * Generate a query and a countquery from all of the information supplied
@@ -63,6 +65,19 @@ class views_plugin_query extends views_plugin {
   function get_aggregation_info() { }
 
   /**
+   * Add settings for the ui.
+   */
+  function options_form(&$form, &$form_state) { }
+
+  function options_validate(&$form, &$form_state) { }
+
+  function options_submit(&$form, &$form_state) { }
+
+  function summary_title() {
+    return t('Settings');
+  }
+
+  /**
    * Set a LIMIT on the query, specifying a maximum number of results.
    */
   function set_limit($limit) {
diff --git plugins/views_plugin_query_default.inc plugins/views_plugin_query_default.inc
index 0ec7cf7..91bcbe4 100644
--- plugins/views_plugin_query_default.inc
+++ plugins/views_plugin_query_default.inc
@@ -71,7 +71,8 @@ class views_plugin_query_default extends views_plugin_query{
   /**
    * Constructor; Create the basic query object and fill with default values.
    */
-  function init($base_table = 'node', $base_field = 'nid') {
+  function init($base_table = 'node', $base_field = 'nid', $options) {
+    parent::init($base_table, $base_field, $options);
     $this->base_table = $base_table;  // Predefine these above, for clarity.
     $this->base_field = $base_field;
     $this->relationships[$base_table] = array(
@@ -149,6 +150,30 @@ class views_plugin_query_default extends views_plugin_query{
     $this->header = $header;
   }
 
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['disable_sql_rewrite'] = array(
+      'default' => FALSE,
+      'translatable' => FALSE,
+      'bool' => TRUE,
+    );
+
+    return $options;
+  }
+
+  /**
+   * Add settings for the ui.
+   */
+  function options_form(&$form, &$form_state) {
+    $form['disable_sql_rewrite'] = array(
+      '#title' => t('Disable SQL rewritting'),
+      '#description' => t('Disabling SQL rewritting will disable node_access checks as well as other modules that implement hook_db_rewrite_sql().'),
+      '#type' => 'checkbox',
+      '#default_value' => !empty($this->options['disable_sql_rewrite']),
+      '#prefix' =>  '<div class="messages warning">' . t('You have to know what you are doing here, be sure that you really want to turn off SQL rewriting') . '</div>',
+    );
+  }
+
   // ----------------------------------------------------------------
   // Table/join adding
 
@@ -1050,8 +1075,12 @@ class views_plugin_query_default extends views_plugin_query{
    */
   function execute(&$view) {
     $external = FALSE; // Whether this query will run against an external database.
-    $query = db_rewrite_sql($view->build_info['query'], $view->base_table, $view->base_field, array('view' => &$view));
-    $count_query = db_rewrite_sql($view->build_info['count_query'], $view->base_table, $view->base_field, array('view' => &$view));
+    $query = $view->build_info['query'];
+    $count_query = $view->build_info['count_query'];
+    if (empty($this->options['disable_sql_rewrite'])) {
+      $query = db_rewrite_sql($view->build_info['query'], $view->base_table, $view->base_field, array('view' => &$view));
+      $count_query = db_rewrite_sql($view->build_info['count_query'], $view->base_table, $view->base_field, array('view' => &$view));
+    }
     $args = $view->build_info['query_args'];
 
     vpr($query);
diff --git views.module views.module
index df229ad..2248283 100644
--- views.module
+++ views.module
@@ -153,6 +153,20 @@ function views_preprocess_comment(&$vars) {
   }
 }
 
+/**
+ * A theme preprocess function to automatically allow blocks with view-based
+ * block templates if called from a view.
+ */
+function views_preprocess_block($vars) {
+  if (!empty($vars['block']->view)) {
+    $vars['view'] = &$vars['block']->view;
+    $vars['template_files'][] = 'block-view-' . $vars['view']->name;
+    if(!empty($vars['view']->current_display)) {
+      $vars['template_files'][] = 'block-view-' . $vars['view']->name . '-' . $vars['view']->current_display;
+    }
+  }
+}
+
 /*
  * Implementation of hook_perm()
  */
