diff --git a/configure.ac b/configure.ac
index 519176f..83e1d79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([1.10.3 dist-bzip2 no-dist-gzip])
 AM_MAINTAINER_MODE([enable])
 
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 # Check for programs
 AC_PROG_CC
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index f3781d5..40a2297 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -40,7 +40,7 @@ libgtksourceview_headers =			\
 	gtksourcecompletionitem.h		\
 	gtksourcecompletionproposal.h		\
 	gtksourcecompletionprovider.h		\
-	gtksourcecompletioncontext.h
+	gtksourcecompletioncontext.h		
 
 NOINST_H_FILES = \
 	gtksourcecompletionmodel.h	\
@@ -55,7 +55,9 @@ NOINST_H_FILES = \
 	gtksourceundomanagerdefault.h	\
 	gtksourceview-i18n.h		\
 	gtksourceview-utils.h		\
-	gtktextregion.h
+	gtktextregion.h			\
+	gtkhighlightengine.h		\
+	gtksourcecontextengine-private.h 
 
 libgtksourceview_2_0_la_SOURCES = 	\
 	gtksourcebuffer.c 		\
@@ -86,6 +88,7 @@ libgtksourceview_2_0_la_SOURCES = 	\
 	gtksourcecompletionmodel.c	\
 	gtksourcecompletionutils.c	\
 	gtksourcecompletioncontext.c 	\
+	gtkhighlightengine.c		\
 	$(libgtksourceview_headers)	\
 	$(NOINST_H_FILES)
 
diff --git a/gtksourceview/gtkhighlightengine.c b/gtksourceview/gtkhighlightengine.c
new file mode 100644
index 0000000..ea0da5c
--- /dev/null
+++ b/gtksourceview/gtkhighlightengine.c
@@ -0,0 +1,938 @@
+/* -*- mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
+ *  gtkhighlightengine.c
+ *
+ *  Copyright (C) 2003 - Gustavo Giráldez <gustavo.giraldez@gmx.net>
+ *  Copyright (C) 2005, 2006 - Marco Barisione, Emanuele Aina
+ *  Copyright (C) 2010 Jose Aliste <jose.aliste@gmail.com>
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Library General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "gtksourceview-i18n.h"
+#include "gtkhighlightengine.h"
+#include "gtktextregion.h"
+#include "gtksourcelanguage-private.h"
+#include "gtksourcebuffer.h"
+#include "gtksourcestyle-private.h"
+#include "gtksourcecontextengine-private.h"
+
+#include <glib.h>
+
+#include <errno.h>
+#include <string.h>
+
+#undef ENABLE_DEBUG
+#undef ENABLE_PROFILE
+#undef ENABLE_CHECK_TREE
+#undef ENABLE_MEMORY_DEBUG /* define it to make it print memory usage information */
+			   /* it won't work with GRegex */
+
+#ifdef ENABLE_DEBUG
+#define DEBUG(x) (x)
+#else
+#define DEBUG(x)
+#endif
+
+#ifdef ENABLE_PROFILE
+#define PROFILE(x) (x)
+#else
+#define PROFILE(x)
+#endif
+
+#if defined (ENABLE_DEBUG) || defined (ENABLE_PROFILE) || \
+    defined (ENABLE_CHECK_TREE)
+#define NEED_DEBUG_ID
+#endif
+
+
+
+
+
+struct _GtkHighlightEnginePrivate
+{
+	GtkTextBuffer		*buffer;
+	GtkSourceStyleScheme	*style_scheme;
+
+	/* All tags indexed by style name: values are GSList's of tags, ref()'ed. */
+	GHashTable		*tags;
+	/* Number of all syntax tags created by the engine, needed to set correct
+	 * tag priorities */
+	guint			 n_tags;
+
+	GHashTable		*context_classes;
+
+	GHashTable		*styles_map;
+
+	/* Whether or not to actually highlight the buffer. */
+	gboolean		 highlight;
+
+	/* Whether highlighting was disabled because of errors. */
+	gboolean		 disabled;
+
+	/* Region covering the unhighlighted text. */
+	GtkTextRegion		*refresh_region;
+
+	/* Pointer to the segment tree created by the syntax analyzer */
+	Segment			*segment_tree;
+        Segment                 *hint;
+        Segment                 *hint2;
+
+	/* Views highlight requests. */
+	GtkTextRegion		*highlight_requests;
+
+#ifdef ENABLE_MEMORY_DEBUG
+	guint			 mem_usage_timeout;
+#endif
+};
+
+
+
+//static GQuark		gtk_highlight_engine_error_quark (void) G_GNUC_CONST;
+
+/* TAGS AND STUFF -------------------------------------------------------------- */
+
+
+static void
+unhighlight_region_cb (G_GNUC_UNUSED gpointer style,
+		       GSList   *tags,
+		       gpointer  user_data)
+{
+	struct BufAndIters *data = user_data;
+
+	while (tags != NULL)
+	{
+		gtk_text_buffer_remove_tag (data->buffer,
+					    tags->data,
+					    data->start,
+					    data->end);
+		tags = tags->next;
+	}
+}
+
+static void
+unhighlight_region (GtkHighlightEngine *ce,
+		    const GtkTextIter      *start,
+		    const GtkTextIter      *end)
+{
+	struct BufAndIters data;
+
+	data.buffer = ce->priv->buffer;
+	data.start = start;
+	data.end = end;
+
+	if (gtk_text_iter_equal (start, end))
+		return;
+
+	g_hash_table_foreach (ce->priv->tags, (GHFunc) unhighlight_region_cb, &data);
+}
+
+#define MAX_STYLE_DEPENDENCY_DEPTH	50
+
+static void
+set_tag_style (GtkHighlightEngine *ce,
+	       GtkTextTag             *tag,
+	       const gchar            *style_id)
+{
+	GtkSourceStyle *style;
+
+	const char *map_to = style_id;
+
+	int guard = 0;
+
+	g_return_if_fail (GTK_IS_TEXT_TAG (tag));
+	g_return_if_fail (style_id != NULL);
+
+	_gtk_source_style_apply (NULL, tag);
+
+	if (ce->priv->style_scheme == NULL)
+		return;
+
+	style = gtk_source_style_scheme_get_style (ce->priv->style_scheme, style_id);
+
+	while (style == NULL)
+	{
+		GtkSourceStyleInfo *info;
+
+		if (guard > MAX_STYLE_DEPENDENCY_DEPTH)
+		{
+			g_warning ("Potential circular dependency between styles detected for style '%s'", style_id);
+			break;
+		}
+
+		++guard;
+
+		/* FIXME Style references really must be fixed, both parser for
+		 * sane use in lang files, and engine for safe use. */
+		info = g_hash_table_lookup (ce->priv->styles_map, map_to);
+
+		map_to = (info != NULL) ? info->map_to : NULL;
+
+		if (!map_to)
+			break;
+
+		style = gtk_source_style_scheme_get_style (ce->priv->style_scheme, map_to);
+	}
+
+	/* not having style is fine, since parser checks validity of every style reference,
+	 * so we don't need to spit a warning here */
+	if (style != NULL)
+		_gtk_source_style_apply (style, tag);
+}
+
+static GtkTextTag *
+create_tag (GtkHighlightEngine *ce,
+	    const gchar        *style_id)
+{
+	GSList *tags;
+	GtkTextTag *new_tag;
+
+	g_assert (style_id != NULL);
+
+	tags = g_hash_table_lookup (ce->priv->tags, style_id);
+
+	new_tag = gtk_text_buffer_create_tag (ce->priv->buffer, NULL, NULL);
+	/* It must have priority lower than user tags but still
+	 * higher than highlighting tags created before */
+	gtk_text_tag_set_priority (new_tag, ce->priv->n_tags);
+	set_tag_style (ce, new_tag, style_id);
+	ce->priv->n_tags += 1;
+
+	tags = g_slist_prepend (tags, g_object_ref (new_tag));
+	g_hash_table_insert (ce->priv->tags, g_strdup (style_id), tags);
+
+	return new_tag;
+}
+
+/* Find tag which has to be overridden. */
+static GtkTextTag *
+get_parent_tag (Context    *context,
+		const char *style)
+{
+	while (context != NULL)
+	{
+		/* Lang files may repeat same style for nested contexts,
+		 * ignore them. */
+		if (context->style &&
+		    strcmp (context->style, style) != 0)
+		{
+			g_assert (context->tag != NULL);
+			return context->tag;
+		}
+
+		context = context->parent;
+	}
+
+	return NULL;
+}
+
+static GtkTextTag *
+get_tag_for_parent (GtkHighlightEngine 	   *ce,
+		    const char             *style,
+		    Context                *parent)
+{
+	GSList *tags;
+	GtkTextTag *parent_tag = NULL;
+	GtkTextTag *tag;
+
+	g_return_val_if_fail (style != NULL, NULL);
+
+	parent_tag = get_parent_tag (parent, style);
+	tags = g_hash_table_lookup (ce->priv->tags, style);
+
+	if (tags && (!parent_tag ||
+		gtk_text_tag_get_priority (tags->data) > gtk_text_tag_get_priority (parent_tag)))
+	{
+		GSList *link;
+
+		tag = tags->data;
+
+		/* Now get the tag with lowest priority, so that tag lists do not grow
+		 * indefinitely. */
+		for (link = tags->next; link != NULL; link = link->next)
+		{
+			if (parent_tag &&
+			    gtk_text_tag_get_priority (link->data) < gtk_text_tag_get_priority (parent_tag))
+				break;
+			tag = link->data;
+		}
+	}
+	else
+	{
+		tag = create_tag (ce, style);
+
+#ifdef ENABLE_DEBUG
+		{
+			GString *style_path = g_string_new (style);
+			gint n;
+
+			while (parent != NULL)
+			{
+				if (parent->style != NULL)
+				{
+					g_string_prepend (style_path, "/");
+					g_string_prepend (style_path,
+							  parent->style);
+				}
+
+				parent = parent->parent;
+			}
+
+			tags = g_hash_table_lookup (ce->priv->tags, style);
+			n = g_slist_length (tags);
+			g_print ("created %d tag for style %s: %s\n", n, style, style_path->str);
+			g_string_free (style_path, TRUE);
+		}
+#endif
+	}
+
+	return tag;
+}
+
+static GtkTextTag *
+get_subpattern_tag (GtkHighlightEngine *ce,
+		    Context                *context,
+		    SubPatternDefinition   *sp_def)
+{
+	if (sp_def->style == NULL)
+		return NULL;
+
+	g_assert (sp_def->index < context->definition->n_sub_patterns);
+
+	if (context->subpattern_tags == NULL)
+		context->subpattern_tags = g_new0 (GtkTextTag*, context->definition->n_sub_patterns);
+
+	if (context->subpattern_tags[sp_def->index] == NULL)
+		context->subpattern_tags[sp_def->index] = get_tag_for_parent (ce, sp_def->style, context);
+
+	g_return_val_if_fail (context->subpattern_tags[sp_def->index] != NULL, NULL);
+	return context->subpattern_tags[sp_def->index];
+}
+
+static GtkTextTag *
+get_context_tag (GtkHighlightEngine *ce,
+		 Context                *context)
+{
+	if (context->style != NULL && context->tag == NULL)
+		context->tag = get_tag_for_parent (ce,
+						   context->style,
+						   context->parent);
+	return context->tag;
+}
+
+static void
+apply_tags (GtkHighlightEngine *ce,
+	    Segment                *segment,
+	    gint                    start_offset,
+	    gint                    end_offset)
+{
+	GtkTextTag *tag;
+	GtkTextIter start_iter, end_iter;
+	GtkTextBuffer *buffer = ce->priv->buffer;
+	SubPattern *sp;
+	Segment *child;
+
+	g_assert (segment != NULL);
+
+	if (SEGMENT_IS_INVALID (segment))
+		return;
+
+	if (segment->start_at >= end_offset || segment->end_at <= start_offset)
+		return;
+
+	start_offset = MAX (start_offset, segment->start_at);
+	end_offset = MIN (end_offset, segment->end_at);
+
+	tag = get_context_tag (ce, segment->context);
+
+	if (tag != NULL)
+	{
+		gint style_start_at, style_end_at;
+
+		style_start_at = start_offset;
+		style_end_at = end_offset;
+
+		if (HAS_OPTION (segment->context->definition, STYLE_INSIDE))
+		{
+			style_start_at = MAX (segment->start_at + segment->start_len, start_offset);
+			style_end_at = MIN (segment->end_at - segment->end_len, end_offset);
+		}
+
+		if (style_start_at > style_end_at)
+		{
+			g_critical ("%s: oops", G_STRLOC);
+		}
+		else
+		{
+			gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, style_start_at);
+			end_iter = start_iter;
+			gtk_text_iter_forward_chars (&end_iter, style_end_at - style_start_at);
+			gtk_text_buffer_apply_tag (ce->priv->buffer, tag, &start_iter, &end_iter);
+		}
+	}
+
+	for (sp = segment->sub_patterns; sp != NULL; sp = sp->next)
+	{
+		if (sp->start_at >= start_offset && sp->end_at <= end_offset)
+		{
+			gint start = MAX (start_offset, sp->start_at);
+			gint end = MIN (end_offset, sp->end_at);
+
+			tag = get_subpattern_tag (ce, segment->context, sp->definition);
+
+			if (tag != NULL)
+			{
+				gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, start);
+				end_iter = start_iter;
+				gtk_text_iter_forward_chars (&end_iter, end - start);
+				gtk_text_buffer_apply_tag (ce->priv->buffer, tag, &start_iter, &end_iter);
+			}
+		}
+	}
+
+	for (child = segment->children;
+	     child != NULL && child->start_at < end_offset;
+	     child = child->next)
+	{
+		if (child->end_at > start_offset)
+			apply_tags (ce, child, start_offset, end_offset);
+	}
+}
+
+/**
+ * highlight_region:
+ *
+ * @ce: a #GtkHighlightEngine.
+ * @start: the beginning of the region to highlight.
+ * @end: the end of the region to highlight.
+ *
+ * Highlights the specified region.
+ */
+static void
+highlight_region (GtkHighlightEngine *ce,
+		  GtkTextIter            *start,
+		  GtkTextIter            *end)
+{
+#ifdef ENABLE_PROFILE
+	GTimer *timer;
+#endif
+
+	if (gtk_text_iter_starts_line (end))
+		gtk_text_iter_backward_char (end);
+	if (gtk_text_iter_compare (start, end) >= 0)
+		return;
+
+#ifdef ENABLE_PROFILE
+	timer = g_timer_new ();
+#endif
+
+	/* First we need to delete tags in the regions. */
+	unhighlight_region (ce, start, end);
+
+	apply_tags (ce, ce->priv->segment_tree,
+		    gtk_text_iter_get_offset (start),
+		    gtk_text_iter_get_offset (end));
+
+#ifdef ENABLE_PROFILE
+	g_print ("highlight (from %d to %d), %g ms elapsed\n",
+		 gtk_text_iter_get_offset (start),
+		 gtk_text_iter_get_offset (end),
+		 g_timer_elapsed (timer, NULL) * 1000);
+	g_timer_destroy (timer);
+#endif
+}
+
+/**
+ * ensure_highlighted:
+ *
+ * @ce: a #GtkHighlightEngine.
+ * @start: the beginning of the region to highlight.
+ * @end: the end of the region to highlight.
+ *
+ * Updates text tags in reanalyzed parts of given area.
+ * It applies tags according to whatever is in the syntax
+ * tree currently, so highlighting may not be correct
+ * (gtk_highlight_engine_update_highlight is the method
+ * that actually ensures correct highlighting).
+ */
+static void
+ensure_highlighted (GtkHighlightEngine *ce,
+		    const GtkTextIter      *start,
+		    const GtkTextIter      *end,
+		    GtkTextRegion	*refresh_region)
+{
+	GtkTextRegion *region;
+	GtkTextRegionIterator reg_iter;
+
+	/* Get the subregions not yet highlighted. */
+	region = gtk_text_region_intersect (refresh_region, start, end);
+
+	if (region == NULL)
+		return;
+
+	gtk_text_region_get_iterator (region, &reg_iter, 0);
+
+	/* Highlight all subregions from the intersection.
+	 * hopefully this will only be one subregion. */
+	while (!gtk_text_region_iterator_is_end (&reg_iter))
+	{
+		GtkTextIter s, e;
+		gtk_text_region_iterator_get_subregion (&reg_iter, &s, &e);
+		highlight_region (ce, &s, &e);
+		gtk_text_region_iterator_next (&reg_iter);
+	}
+
+	gtk_text_region_destroy (region, TRUE);
+
+	/* Remove the just highlighted region. */
+	gtk_text_region_subtract (ce->priv->refresh_region, start, end);
+}
+
+/**
+ * refresh_range:
+ *
+ * @ce: a #GtkHighlightEngine.
+ * @start: the beginning of updated area.
+ * @end: the end of updated area.
+ * @modify_refresh_region: whether updated area should be added to
+ * refresh_region.
+ *
+ * Marks the area as updated - notifies view about it, and adds it to
+ * refresh_region if @modify_refresh_region is %TRUE (update_syntax may
+ * process huge area though actually updated is couple of lines, so in
+ * that case update_syntax() takes care of refresh_region, and this
+ * function only notifies the view).
+ */
+
+static void
+refresh_range (GtkHighlightEngine *ce,
+	       const GtkTextIter      *start,
+	       const GtkTextIter      *end,
+	       gboolean                modify_refresh_region)
+{
+	GtkTextIter real_end;
+
+	if (gtk_text_iter_equal (start, end))
+		return;
+
+	if (modify_refresh_region)
+		gtk_text_region_add (ce->priv->refresh_region, start, end);
+
+	/* Now context classes are refreshed in gtksourcecontextengine */
+	/* Refresh the contex classes here */
+	/* refresh_context_classes (ce, start, end); */
+
+	/* Here we need to make sure we do not make it redraw next line */
+	real_end = *end;
+	if (gtk_text_iter_starts_line (&real_end))
+		/* I don't quite like this here, but at least it won't jump into
+		 * the middle of \r\n  */
+		gtk_text_iter_backward_cursor_position (&real_end);
+
+	g_signal_emit_by_name (ce->priv->buffer,
+			       "highlight_updated",
+			       start,
+			       &real_end);
+}
+
+/**
+ * invalidate_region:
+ *
+ * @ce: a #GtkHighlightEngine.
+ * @offset: the start of invalidated area.
+ * @length: the length of the area.
+ *
+ * Adds the area to the invalid region and queues highlighting.
+ * @length may be negative which means deletion; positive
+ * means insertion; 0 means "something happened here", it's
+ * treated as zero-length insertion.
+ */
+ /*
+static void
+invalidate_region (GtkHighlightEngine *ce,
+		   gint                    offset,
+		   gint                    length)
+{
+	InvalidRegion *region = &ce->priv->invalid_region;
+	GtkTextBuffer *buffer = ce->priv->buffer;
+	GtkTextIter iter;
+	gint end_offset;
+
+	end_offset = length >= 0 ? offset + length : offset;
+
+	if (region->empty)
+	{
+		region->empty = FALSE;
+		region->delta = length;
+
+		gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
+		gtk_text_buffer_move_mark (buffer, region->start, &iter);
+
+		gtk_text_iter_set_offset (&iter, end_offset);
+		gtk_text_buffer_move_mark (buffer, region->end, &iter);
+	}
+	else
+	{
+		gtk_text_buffer_get_iter_at_mark (buffer, &iter, region->start);
+
+		if (gtk_text_iter_get_offset (&iter) > offset)
+		{
+			gtk_text_iter_set_offset (&iter, offset);
+			gtk_text_buffer_move_mark (buffer, region->start, &iter);
+		}
+
+		gtk_text_buffer_get_iter_at_mark (buffer, &iter, region->end);
+
+		if (gtk_text_iter_get_offset (&iter) < end_offset)
+		{
+			gtk_text_iter_set_offset (&iter, end_offset);
+			gtk_text_buffer_move_mark (buffer, region->end, &iter);
+		}
+
+		region->delta += length;
+	}
+
+	DEBUG (({
+		gint start, end;
+		gtk_text_buffer_get_iter_at_mark (buffer, &iter, region->start);
+		start = gtk_text_iter_get_offset (&iter);
+		gtk_text_buffer_get_iter_at_mark (buffer, &iter, region->end);
+		end = gtk_text_iter_get_offset (&iter);
+		g_assert (start <= end - region->delta);
+	}));
+
+	CHECK_TREE (ce);
+
+	install_first_update (ce);
+}*/
+
+/**
+ * update_highlight_cb:
+ *
+ * @ce: a #GtkHighlightEngine.
+ * @start: start of area to update.
+ * @end: start of area to update.
+ * @synchronous: whether it should block until everything
+ * is analyzed/highlighted.
+ *
+ * GtkSourceEngine::update_highlight method.
+ *
+ * Makes sure the area is analyzed and highlighted. If @synchronous
+ * is %FALSE, then it queues idle worker.
+ */
+static void
+update_highlight_cb (GtkHighlightEngine *highlight_engine,
+		     const GtkTextIter *start,
+		     const GtkTextIter *end,
+		   //  GtkTextRegion     *refresh_region, 
+		     GtkSourceBuffer *buffer)
+{
+	printf("Catched signal. Tree = %p, From %d to %d\n",
+			highlight_engine->priv->segment_tree,
+			gtk_text_iter_get_offset(start), gtk_text_iter_get_offset(end));
+	if (!highlight_engine->priv->highlight)
+		return;
+	
+	highlight_region (highlight_engine, start, end);// refresh_region);
+}
+
+/**
+ * enable_highlight:
+ *
+ * @ce: a #GtkHighlightEngine.
+ * @enable: whether to enable highlighting.
+ *
+ * Whether to highlight (i.e. apply tags) analyzed area.
+ * Note that this does not turn on/off the analyzis stuff,
+ * it affects only text tags.
+ */
+static void
+enable_highlight (GtkHighlightEngine *ce,
+		  gboolean                enable)
+{
+	GtkTextIter start, end;
+
+	if (!enable == !ce->priv->highlight)
+		return;
+
+	ce->priv->highlight = enable != 0;
+	gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (ce->priv->buffer),
+				    &start, &end);
+
+	if (enable)
+		refresh_range (ce, &start, &end, TRUE);
+	else
+		unhighlight_region (ce, &start, &end);
+}
+
+static void
+buffer_notify_highlight_syntax_cb (GtkHighlightEngine *ce)
+{
+	gboolean highlight;
+	g_object_get (ce->priv->buffer, "highlight-syntax", &highlight, NULL);
+	enable_highlight (ce, highlight);
+}
+
+G_DEFINE_TYPE (GtkHighlightEngine, _gtk_highlight_engine, G_TYPE_OBJECT)
+
+/* GtkHighlightEngine class ------------------------------------------- */
+#if 0
+
+static GQuark
+gtk_highlight_engine_error_quark (void)
+{
+	static GQuark err_q = 0;
+	if (err_q == 0)
+		err_q = g_quark_from_static_string ("gtk-source-context-engine-error-quark");
+	return err_q;
+}
+#endif
+
+static void
+remove_tags_hash_cb (G_GNUC_UNUSED gpointer style,
+		     GSList          *tags,
+		     GtkTextTagTable *table)
+{
+	GSList *l = tags;
+
+	while (l != NULL)
+	{
+		gtk_text_tag_table_remove (table, l->data);
+		g_object_unref (l->data);
+		l = l->next;
+	}
+
+	g_slist_free (tags);
+}
+/**
+ * destroy_tags_hash:
+ *
+ * @ce: #GtkHighlightEngine.
+ *
+ * Destroys syntax tags cache.
+ */
+/*static void
+destroy_tags_hash (GtkHighlightEngine *ce)
+{
+	g_hash_table_foreach (ce->priv->tags, (GHFunc) remove_tags_hash_cb,
+                              gtk_text_buffer_get_tag_table (ce->priv->buffer));
+	g_hash_table_destroy (ce->priv->tags);
+	ce->priv->tags = NULL;
+}
+*/
+
+/*
+ * gtk_highlight_engine_attach_buffer:
+ *
+ * @ce: #GtkHighlightEngine.
+ * @buffer: buffer.
+ *
+ * Detaches engine from previous buffer, and attaches to @buffer if
+ * it's not %NULL.
+ */
+ /* THIS SHOULD BE MODIFIED TO ATTACH SYNTAX_ENGINE */
+void
+_gtk_highlight_engine_attach_buffer_and_analyzer (GtkHighlightEngine *engine,
+				  		  GtkTextBuffer      *buffer,
+				  		  GtkSourceEngine    *se)
+{
+	GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (se);
+
+	//g_return_if_fail (!buffer || GTK_IS_CONTEXT_ (buffer));
+	printf ("Attaching buffer\n");
+	if (engine->priv->buffer == buffer)
+		return;
+
+	/* Detach previous buffer if there is one. */
+	if (engine->priv->buffer != NULL)
+	{
+		g_signal_handlers_disconnect_by_func (engine->priv->buffer,
+						      (gpointer) buffer_notify_highlight_syntax_cb,
+						      engine);
+		/*if (ce->priv->root_segment != NULL)
+			segment_destroy (ce, ce->priv->root_segment);
+		Should I set NULL the segment_tree?
+			ce->priv->root_segment = NULL;
+		*/
+		
+		/* this deletes tags from the tag table, therefore there is no need
+		 * in removing tags from the text (it may be very slow).
+		 * FIXME: don't we want to just destroy and forget everything when
+		 * the buffer is destroyed? Removing tags is still slower than doing
+		 * nothing. Caveat: if tag table is shared with other buffer, we do
+		 * need to remove tags. */
+		/*destroy_tags_hash (ce);
+		ce->priv->n_tags = 0;*/
+
+/*		if (ce->priv->refresh_region != NULL)
+			gtk_text_region_destroy (ce->priv->refresh_region, FALSE);
+		if (ce->priv->highlight_requests != NULL)
+			gtk_text_region_destroy (ce->priv->highlight_requests, FALSE);
+			*/
+	//	ce->priv->refresh_region = NULL;
+	//	ce->priv->highlight_requests = NULL;
+	}
+
+	engine->priv->buffer = buffer;
+
+	if (buffer != NULL)
+	{
+		
+		//ce->priv->root_segment = create_segment (ce, NULL, ce->priv->root_context, 0, 0, TRUE, NULL);
+		engine->priv->tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+		
+		//gtk_text_buffer_get_bounds (buffer, &start, &end);
+		
+		g_object_get (engine->priv->buffer, "highlight-syntax", &engine->priv->highlight, NULL);
+		//ce->priv->refresh_region = gtk_text_region_new (buffer);
+		//ce->priv->highlight_requests = gtk_text_region_new (buffer);
+
+		g_signal_connect_swapped (buffer,
+					  "notify::highlight-syntax",
+					  G_CALLBACK (buffer_notify_highlight_syntax_cb),
+					  engine);
+		printf("Tree = %p\n", engine->priv->segment_tree);
+		engine->priv->segment_tree = _gtk_source_context_engine_get_tree (ce);
+		printf("Connecting to signal, tree = %p  \n", engine->priv->segment_tree);
+		g_signal_connect_swapped (buffer, "highlight_updated", 
+					  G_CALLBACK (update_highlight_cb),
+					  engine);
+
+	//	install_first_update (ce);
+	}
+}
+
+
+static void
+set_tag_style_hash_cb (const char             *style,
+		       GSList                 *tags,
+		       GtkHighlightEngine *ce)
+{
+	while (tags != NULL)
+	{
+		set_tag_style (ce, tags->data, style);
+		tags = tags->next;
+	}
+}
+
+/**
+ * gtk_highlight_engine_set_style_scheme:
+ *
+ * @engine: #GtkHighlightEngine.
+ * @scheme: #GtkSourceStyleScheme to set.
+ *
+ * GtkSourceEngine::set_style_scheme method.
+ * Sets current style scheme, updates tag styles and everything.
+ */
+void
+_gtk_highlight_engine_set_style_scheme (GtkHighlightEngine      *engine,
+				       GtkSourceStyleScheme *scheme)
+				  {
+	GtkHighlightEngine *ce;
+
+	g_return_if_fail (GTK_IS_HIGHLIGHT_ENGINE (engine));
+	g_return_if_fail (GTK_IS_SOURCE_STYLE_SCHEME (scheme) || scheme == NULL);
+
+	ce = GTK_HIGHLIGHT_ENGINE (engine);
+
+	if (scheme != ce->priv->style_scheme)
+	{
+		if (ce->priv->style_scheme != NULL)
+			g_object_unref (ce->priv->style_scheme);
+
+		ce->priv->style_scheme = scheme ? g_object_ref (scheme) : NULL;
+		g_hash_table_foreach (ce->priv->tags, (GHFunc) set_tag_style_hash_cb, ce);
+	}
+		 
+}
+
+void
+_gtk_highlight_engine_set_styles_map (GtkHighlightEngine      *engine,
+				       GHashTable	    *styles)
+{
+	GtkHighlightEngine *ce;
+
+	g_return_if_fail (GTK_IS_HIGHLIGHT_ENGINE (engine));
+	//g_return_if_fail (G_IS_HASH_TABLE (styles) || styles == NULL);
+
+	ce = GTK_HIGHLIGHT_ENGINE (engine);
+
+	if (ce->priv->styles_map != styles)
+	{
+		if (ce->priv->styles_map != NULL)
+		{
+		//g_object_unref (ce->priv->styles_map);
+		}
+		ce->priv->styles_map = styles;// ? g_object_ref (styles) : NULL;
+	}
+	 
+}
+static void
+gtk_highlight_engine_finalize (GObject *object)
+{
+	GtkHighlightEngine *ce = GTK_HIGHLIGHT_ENGINE (object);
+
+	if (ce->priv->buffer != NULL)
+	{
+		g_critical ("finalizing engine with attached buffer");
+		/* Disconnect the buffer (if there is one), which destroys almost
+		 * everything. */
+		//gtk_highlight_engine_attach_buffer (GTK_SOURCE_ENGINE (ce), NULL);
+	}
+
+	g_assert (!ce->priv->tags);
+	//g_assert (!ce->priv->root_context);
+	g_assert (!ce->priv->segment_tree);
+	
+	if (ce->priv->style_scheme != NULL)
+		g_object_unref (ce->priv->style_scheme);
+
+	G_OBJECT_CLASS (_gtk_highlight_engine_parent_class)->finalize (object);
+}
+
+static void
+_gtk_highlight_engine_class_init (GtkHighlightEngineClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	//GtkSourceEngineClass *engine_class = GTK_SOURCE_ENGINE_CLASS (klass);
+
+	object_class->finalize = gtk_highlight_engine_finalize;
+	/*
+	engine_class->attach_buffer = gtk_highlight_engine_attach_buffer;
+	engine_class->text_inserted = gtk_highlight_engine_text_inserted;
+	engine_class->text_deleted = gtk_highlight_engine_text_deleted;
+	engine_class->update_highlight = gtk_highlight_engine_update_highlight;
+	engine_class->set_style_scheme = gtk_highlight_engine_set_style_scheme;
+	engine_class->get_context_class_tag = gtk_highlight_engine_get_context_class_tag;
+	*/
+	g_type_class_add_private (object_class, sizeof (GtkHighlightEnginePrivate));
+}
+
+static void
+_gtk_highlight_engine_init (GtkHighlightEngine *ce)
+{
+	ce->priv = G_TYPE_INSTANCE_GET_PRIVATE (ce, GTK_TYPE_HIGHLIGHT_ENGINE,
+						GtkHighlightEnginePrivate);
+}
+
+GtkHighlightEngine * 	
+_gtk_highlight_engine_new ()
+{
+	GtkHighlightEngine *ce;
+
+	ce = g_object_new (GTK_TYPE_HIGHLIGHT_ENGINE, NULL);
+	ce->priv->segment_tree = NULL;
+
+	return ce;
+}
+
diff --git a/gtksourceview/gtkhighlightengine.h b/gtksourceview/gtkhighlightengine.h
new file mode 100644
index 0000000..de005aa
--- /dev/null
+++ b/gtksourceview/gtkhighlightengine.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
+ *  gtkhighlightengine.h
+ *
+ *  Copyright (C) 2003 - Gustavo Giráldez
+ *  Copyright (C) 2005 - Marco Barisione, Emanuele Aina
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Library General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_HIGHLIGHT_ENGINE_H__
+#define __GTK_HIGHLIGHT_ENGINE_H__
+
+#include <gtksourceview/gtksourcebuffer.h>
+#include <gtksourceview/gtksourceengine.h>
+#include <gtksourceview/gtksourcelanguage.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_HIGHLIGHT_ENGINE            (_gtk_highlight_engine_get_type ())
+#define GTK_HIGHLIGHT_ENGINE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_HIGHLIGHT_ENGINE, GtkHighlightEngine))
+#define GTK_HIGHLIGHT_ENGINE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_HIGHLIGHT_ENGINE, GtkHighlightEngineClass))
+#define GTK_IS_HIGHLIGHT_ENGINE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_HIGHLIGHT_ENGINE))
+#define GTK_IS_HIGHLIGHT_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HIGHLIGHT_ENGINE))
+#define GTK_HIGHLIGHT_ENGINE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_HIGHLIGHT_ENGINE, GtkHighlightEngineClass))
+
+typedef struct _GtkHighlightData          GtkHighlightData;
+typedef struct _GtkHighlightReplace       GtkHighlightReplace;
+typedef struct _GtkHighlightClass         GtkHighlightClass;
+typedef struct _GtkHighlightEngine        GtkHighlightEngine;
+typedef struct _GtkHighlightEngineClass   GtkHighlightEngineClass;
+typedef struct _GtkHighlightEnginePrivate GtkHighlightEnginePrivate;
+
+struct _GtkHighlightEngine
+{
+	GObject parent_instance;
+
+	/*< private >*/
+	GtkHighlightEnginePrivate *priv;
+};
+
+struct _GtkHighlightEngineClass
+{
+	GObjectClass parent_class;
+};
+
+typedef enum {
+	GTK_HIGHLIGHT_EXTEND_PARENT	= 1 << 0,
+	GTK_HIGHLIGHT_END_PARENT		= 1 << 1,
+	GTK_HIGHLIGHT_END_AT_LINE_END	= 1 << 2,
+	GTK_HIGHLIGHT_FIRST_LINE_ONLY	= 1 << 3,
+	GTK_HIGHLIGHT_ONCE_ONLY		= 1 << 4,
+	GTK_HIGHLIGHT_STYLE_INSIDE		= 1 << 5
+} GtkHighlightFlags;
+
+typedef enum {
+	GTK_HIGHLIGHT_IGNORE_STYLE		= 1 << 0,
+	GTK_HIGHLIGHT_OVERRIDE_STYLE	= 1 << 1,
+	GTK_HIGHLIGHT_REF_ORIGINAL		= 1 << 2
+} GtkHighlightRefOptions;
+
+GType		 _gtk_highlight_engine_get_type	(void) G_GNUC_CONST;
+
+GtkHighlightEngine * 	_gtk_highlight_engine_new ();
+void 			_gtk_highlight_engine_set_style_scheme (GtkHighlightEngine      *engine,
+				       				GtkSourceStyleScheme *scheme);
+void 			_gtk_highlight_engine_set_styles_map (GtkHighlightEngine      *engine,
+				       			      GHashTable *styles);
+
+void			_gtk_highlight_engine_attach_buffer_and_analyzer (GtkHighlightEngine *engine,
+				  			        GtkTextBuffer    *buffer,
+				  			        GtkSourceEngine    *se);
+G_END_DECLS
+
+#endif /* __GTK_HIGHLIGHT_ENGINE_H__ */
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index edbcab8..cb706ea 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -40,6 +40,7 @@
 #include "gtksourcestyleschememanager.h"
 #include "gtksourcestyle-private.h"
 #include "gtksourceundomanagerdefault.h"
+#include "gtkhighlightengine.h"
 
 /**
  * SECTION:buffer
@@ -102,11 +103,13 @@ enum {
 	PROP_MAX_UNDO_LEVELS,
 	PROP_LANGUAGE,
 	PROP_STYLE_SCHEME,
-	PROP_UNDO_MANAGER
+	PROP_UNDO_MANAGER,
+	PROP_ANALYZE_SYNTAX
 };
 
 struct _GtkSourceBufferPrivate
 {
+	gint		       analyze_syntax:1;
 	gint                   highlight_syntax:1;
 	gint                   highlight_brackets:1;
 
@@ -120,7 +123,8 @@ struct _GtkSourceBufferPrivate
 
 	GtkSourceLanguage     *language;
 
-	GtkSourceEngine       *highlight_engine;
+	GtkSourceEngine       *syntax_analyzer;
+	GtkHighlightEngine    *highlight_engine;
 	GtkSourceStyleScheme  *style_scheme;
 
 	GtkSourceUndoManager  *undo_manager;
@@ -213,6 +217,14 @@ gtk_source_buffer_class_init (GtkSourceBufferClass *klass)
 								 "in the buffer"),
 							       TRUE,
 							       G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_ANALYZE_SYNTAX,
+					 g_param_spec_boolean ("analyze-syntax",
+							     _("Analyze syntax"),
+							     _("Whether the syntax of the "
+							       "buffer should be analyzed"),
+							       TRUE,
+							       G_PARAM_READWRITE));
 
 	/**
 	 * GtkSourceBuffer:highlight-matching-brackets:
@@ -296,6 +308,7 @@ gtk_source_buffer_class_init (GtkSourceBufferClass *klass)
 
 	param_types[0] = GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE;
 	param_types[1] = GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE;
+	//_types[2] = G_TYPE_POINTER;
 
 	buffer_signals[HIGHLIGHT_UPDATED] =
 	    g_signal_newv ("highlight_updated",
@@ -399,6 +412,7 @@ gtk_source_buffer_init (GtkSourceBuffer *buffer)
 
 	buffer->priv = priv;
 
+	priv->analyze_syntax = TRUE;
 	priv->highlight_syntax = TRUE;
 	priv->highlight_brackets = TRUE;
 	priv->bracket_mark = NULL;
@@ -469,11 +483,11 @@ gtk_source_buffer_dispose (GObject *object)
 		set_undo_manager (buffer, NULL);
 	}
 
-	if (buffer->priv->highlight_engine != NULL)
+	if (buffer->priv->syntax_analyzer != NULL)
 	{
-		_gtk_source_engine_attach_buffer (buffer->priv->highlight_engine, NULL);
-		g_object_unref (buffer->priv->highlight_engine);
-		buffer->priv->highlight_engine = NULL;
+		_gtk_source_engine_attach_buffer (buffer->priv->syntax_analyzer, NULL);
+		g_object_unref (buffer->priv->syntax_analyzer);
+		buffer->priv->syntax_analyzer = NULL;
 	}
 
 	if (buffer->priv->language != NULL)
@@ -535,6 +549,10 @@ gtk_source_buffer_set_property (GObject      *object,
 			                                    g_value_get_object (value));
 			break;
 
+		case PROP_ANALYZE_SYNTAX:
+			gtk_source_buffer_set_analyze_syntax (source_buffer, 
+							      g_value_get_boolean (value));
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 			break;
@@ -590,6 +608,10 @@ gtk_source_buffer_get_property (GObject    *object,
 			g_value_set_object (value, source_buffer->priv->undo_manager);
 			break;
 
+                case PROP_ANALYZE_SYNTAX:
+                        g_value_set_boolean (value, 
+					     source_buffer->priv->analyze_syntax);
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 			break;
@@ -769,8 +791,8 @@ gtk_source_buffer_content_inserted (GtkTextBuffer *buffer,
 	gtk_text_buffer_get_iter_at_mark (buffer, &insert_iter, mark);
 	gtk_source_buffer_move_cursor (buffer, &insert_iter, mark);
 
-	if (source_buffer->priv->highlight_engine != NULL)
-		_gtk_source_engine_text_inserted (source_buffer->priv->highlight_engine,
+	if (source_buffer->priv->syntax_analyzer != NULL)
+		_gtk_source_engine_text_inserted (source_buffer->priv->syntax_analyzer,
 						  start_offset,
 						  end_offset);
 }
@@ -885,8 +907,8 @@ gtk_source_buffer_real_delete_range (GtkTextBuffer *buffer,
 	gtk_source_buffer_move_cursor (buffer, &iter, mark);
 
 	/* emit text deleted for engines */
-	if (source_buffer->priv->highlight_engine != NULL)
-		_gtk_source_engine_text_deleted (source_buffer->priv->highlight_engine,
+	if (source_buffer->priv->syntax_analyzer != NULL)
+		_gtk_source_engine_text_deleted (source_buffer->priv->syntax_analyzer,
 						 offset, length);
 }
 
@@ -1347,6 +1369,50 @@ gtk_source_buffer_set_highlight_syntax (GtkSourceBuffer *buffer,
 }
 
 /**
+ * gtk_source_buffer_get_analyze_syntax:
+ * @buffer: a #GtkSourceBuffer.
+ *
+ * Determines whether syntax highlighting is activated in the source
+ * buffer.
+ *
+ * Return value: %TRUE if syntax highlighting is enabled, %FALSE otherwise.
+ **/
+gboolean
+gtk_source_buffer_get_analyze_syntax (GtkSourceBuffer *buffer)
+{
+	g_return_val_if_fail (GTK_IS_SOURCE_BUFFER (buffer), FALSE);
+
+	return (buffer->priv->analyze_syntax != FALSE);
+}
+
+/**
+ * gtk_source_buffer_set_analyze_syntax:
+ * @buffer: a #GtkSourceBuffer.
+ * @analyze: %TRUE to enable syntax analysis, %FALSE to disable it.
+ *
+ * Controls whether to analyze the syntax of the buffer. If @analyze
+ * is %TRUE, a syntax text will be highlighted according to the syntax
+ * patterns specified in the language set with
+ * gtk_source_buffer_set_language(). If @highlight is %FALSE, syntax highlighting
+ * is disabled and all the GtkTextTag objects that have been added by the
+ * syntax highlighting engine are removed from the buffer.
+ **/
+void
+gtk_source_buffer_set_analyze_syntax (GtkSourceBuffer *buffer,
+					gboolean         analyze)
+{
+	g_return_if_fail (GTK_IS_SOURCE_BUFFER (buffer));
+
+	analyze = (analyze != FALSE);
+
+	if (buffer->priv->analyze_syntax != analyze)
+	{
+		buffer->priv->analyze_syntax = analyze;
+		g_object_notify (G_OBJECT (buffer), "analyze-syntax");
+	}
+}
+
+/**
  * gtk_source_buffer_set_language:
  * @buffer: a #GtkSourceBuffer.
  * @language: a #GtkSourceLanguage to set, or %NULL.
@@ -1369,12 +1435,12 @@ gtk_source_buffer_set_language (GtkSourceBuffer   *buffer,
 	if (buffer->priv->language == language)
 		return;
 
-	if (buffer->priv->highlight_engine != NULL)
+	if (buffer->priv->syntax_analyzer != NULL)
 	{
 		/* disconnect the old engine */
-		_gtk_source_engine_attach_buffer (buffer->priv->highlight_engine, NULL);
-		g_object_unref (buffer->priv->highlight_engine);
-		buffer->priv->highlight_engine = NULL;
+		_gtk_source_engine_attach_buffer (buffer->priv->syntax_analyzer, NULL);
+		g_object_unref (buffer->priv->syntax_analyzer);
+		buffer->priv->syntax_analyzer = NULL;
 	}
 
 	if (buffer->priv->language != NULL)
@@ -1387,15 +1453,21 @@ gtk_source_buffer_set_language (GtkSourceBuffer   *buffer,
 		g_object_ref (language);
 
 		/* get a new engine */
-		buffer->priv->highlight_engine = _gtk_source_language_create_engine (language);
+		buffer->priv->syntax_analyzer = _gtk_source_language_create_engine (language);
+		buffer->priv->highlight_engine = _gtk_highlight_engine_new ();
+		printf("Highlighting engine NULL ? %d\n", buffer->priv->highlight_engine==NULL);
 
-		if (buffer->priv->highlight_engine)
+		if (buffer->priv->syntax_analyzer)
 		{
-			_gtk_source_engine_attach_buffer (buffer->priv->highlight_engine,
+			_gtk_source_engine_attach_buffer (buffer->priv->syntax_analyzer,
 							  GTK_TEXT_BUFFER (buffer));
-
+			_gtk_highlight_engine_attach_buffer_and_analyzer (buffer->priv->highlight_engine,
+									  GTK_TEXT_BUFFER(buffer),
+									  buffer->priv->syntax_analyzer);
+			_gtk_highlight_engine_set_styles_map (buffer->priv->highlight_engine, 
+								language->priv->styles);
 			if (buffer->priv->style_scheme)
-				_gtk_source_engine_set_style_scheme (buffer->priv->highlight_engine,
+				_gtk_highlight_engine_set_style_scheme (buffer->priv->highlight_engine,
 								     buffer->priv->style_scheme);
 		}
 	}
@@ -1438,8 +1510,8 @@ _gtk_source_buffer_update_highlight (GtkSourceBuffer   *buffer,
 {
 	g_return_if_fail (GTK_IS_SOURCE_BUFFER (buffer));
 
-	if (buffer->priv->highlight_engine != NULL)
-		_gtk_source_engine_update_highlight (buffer->priv->highlight_engine,
+	if (buffer->priv->syntax_analyzer != NULL)
+		_gtk_source_engine_update (buffer->priv->syntax_analyzer,
 						     start,
 						     end,
 						     synchronous);
@@ -1496,9 +1568,9 @@ gtk_source_buffer_set_style_scheme (GtkSourceBuffer      *buffer,
 	buffer->priv->style_scheme = scheme ? g_object_ref (scheme) : NULL;
 	update_bracket_match_style (buffer);
 
-	if (buffer->priv->highlight_engine != NULL)
-		_gtk_source_engine_set_style_scheme (buffer->priv->highlight_engine,
-						     scheme);
+	if (buffer->priv->syntax_analyzer != NULL)
+		_gtk_highlight_engine_set_style_scheme (buffer->priv->highlight_engine,
+						        scheme);
 
 	g_object_notify (G_OBJECT (buffer), "style-scheme");
 }
@@ -2108,12 +2180,12 @@ gtk_source_buffer_iter_has_context_class (GtkSourceBuffer   *buffer,
 	g_return_val_if_fail (iter != NULL, FALSE);
 	g_return_val_if_fail (context_class != NULL, FALSE);
 
-	if (buffer->priv->highlight_engine == NULL)
+	if (buffer->priv->syntax_analyzer == NULL)
 	{
 		return FALSE;
 	}
 
-	tag = _gtk_source_engine_get_context_class_tag (buffer->priv->highlight_engine,
+	tag = _gtk_source_engine_get_context_class_tag (buffer->priv->syntax_analyzer,
 							context_class);
 
 	if (tag != NULL)
@@ -2194,12 +2266,12 @@ gtk_source_buffer_iter_forward_to_context_class_toggle (GtkSourceBuffer *buffer,
 	g_return_val_if_fail (iter != NULL, FALSE);
 	g_return_val_if_fail (context_class != NULL, FALSE);
 
-	if (buffer->priv->highlight_engine == NULL)
+	if (buffer->priv->syntax_analyzer == NULL)
 	{
 		return FALSE;
 	}
 
-	tag = _gtk_source_engine_get_context_class_tag (buffer->priv->highlight_engine,
+	tag = _gtk_source_engine_get_context_class_tag (buffer->priv->syntax_analyzer,
 							context_class);
 
 	if (tag == NULL)
@@ -2239,12 +2311,12 @@ gtk_source_buffer_iter_backward_to_context_class_toggle (GtkSourceBuffer *buffer
 	g_return_val_if_fail (iter != NULL, FALSE);
 	g_return_val_if_fail (context_class != NULL, FALSE);
 
-	if (buffer->priv->highlight_engine == NULL)
+	if (buffer->priv->syntax_analyzer == NULL)
 	{
 		return FALSE;
 	}
 
-	tag = _gtk_source_engine_get_context_class_tag (buffer->priv->highlight_engine,
+	tag = _gtk_source_engine_get_context_class_tag (buffer->priv->syntax_analyzer,
 							context_class);
 
 	if (tag == NULL)
diff --git a/gtksourceview/gtksourcebuffer.h b/gtksourceview/gtksourcebuffer.h
index 8d62949..03c755a 100644
--- a/gtksourceview/gtksourcebuffer.h
+++ b/gtksourceview/gtksourcebuffer.h
@@ -100,6 +100,9 @@ GtkSourceStyleScheme    *gtk_source_buffer_get_style_scheme     (GtkSourceBuffer
 void			 gtk_source_buffer_set_style_scheme     (GtkSourceBuffer        *buffer,
 								 GtkSourceStyleScheme   *scheme);
 
+gboolean		 gtk_source_buffer_get_analyze_syntax	(GtkSourceBuffer        *buffer);
+void			 gtk_source_buffer_set_analyze_syntax	(GtkSourceBuffer        *buffer,
+								 gboolean                analyze);
 /* Force highlighting */
 void			 gtk_source_buffer_ensure_highlight     (GtkSourceBuffer        *buffer,
 								 const GtkTextIter      *start,
diff --git a/gtksourceview/gtksourcecontextengine-private.h b/gtksourceview/gtksourcecontextengine-private.h
new file mode 100644
index 0000000..dee68f4
--- /dev/null
+++ b/gtksourceview/gtksourcecontextengine-private.h
@@ -0,0 +1,205 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
+ * gtksourcecontextengine-private.h
+ * This file is part of gtksourceview
+ *
+ * Copyright (C) 2010 - Jose Aliste <jose.aliste@gmail.com>
+ *
+ * gtksourceview is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * gtksourceview is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __GTK_SOURCE_CONTEXT_ENGINE_PRIVATE_H__
+#define __GTK_SOURCE_CONTEXT_ENGINE_PRIVATE_H__
+
+#define HAS_OPTION(def,opt) (((def)->flags & GTK_SOURCE_CONTEXT_##opt) != 0)
+#define CONTEXT_IS_SIMPLE(c) ((c)->definition->type == CONTEXT_TYPE_SIMPLE)
+#define CONTEXT_IS_CONTAINER(c) ((c)->definition->type == CONTEXT_TYPE_CONTAINER)
+#define SEGMENT_IS_INVALID(s) ((s)->context == NULL)
+#define SEGMENT_IS_SIMPLE(s) CONTEXT_IS_SIMPLE ((s)->context)
+#define SEGMENT_IS_CONTAINER(s) CONTEXT_IS_CONTAINER ((s)->context)
+
+
+struct BufAndIters {
+	GtkTextBuffer *buffer;
+	const GtkTextIter *start, *end;
+};
+
+typedef enum {
+	CONTEXT_TYPE_SIMPLE = 0,
+	CONTEXT_TYPE_CONTAINER
+} ContextType;
+
+typedef enum {
+	SUB_PATTERN_WHERE_DEFAULT = 0,
+	SUB_PATTERN_WHERE_START,
+	SUB_PATTERN_WHERE_END
+} SubPatternWhere;
+
+typedef struct _RegexInfo RegexInfo;
+typedef struct _RegexAndMatch RegexAndMatch;
+typedef struct _Regex Regex;
+typedef struct _SubPatternDefinition SubPatternDefinition;
+typedef struct _SubPattern SubPattern;
+typedef struct _Segment Segment;
+typedef struct _Context Context;
+typedef struct _ContextPtr ContextPtr;
+typedef struct _ContextDefinition ContextDefinition;
+typedef struct _DefinitionChild DefinitionChild;
+typedef struct _DefinitionsIter DefinitionsIter;
+typedef struct _LineInfo LineInfo;
+typedef struct _InvalidRegion InvalidRegion;
+typedef struct _ContextClassTag ContextClassTag;
+
+struct _GtkSourceContextClass
+{
+	gchar    *name;
+	gboolean  enabled;
+};
+
+struct _ContextClassTag
+{
+	GtkTextTag *tag;
+	gboolean enabled;
+};
+
+struct _Context
+{
+	/* Definition for the context. */
+	ContextDefinition	*definition;
+
+	Context			*parent;
+	ContextPtr		*children;
+
+	/* This is the regex returned by regex_resolve() called on
+	 * definition->start_end.end. */
+	Regex			*end;
+	/* The regular expression containing every regular expression that
+	 * could be matched in this context. */
+	Regex			*reg_all;
+
+	/* Either definition->default_style or child_def->style, not copied. */
+	const gchar		*style;
+	GtkTextTag		*tag;
+	GtkTextTag	       **subpattern_tags;
+
+	/* Cache for generated list of class tags */
+	GSList                  *context_classes;
+
+	/* Cache for generated list of subpattern class tags */
+	GSList                 **subpattern_context_classes;
+
+	guint			 ref_count;
+	/* see context_freeze() */
+	guint                    frozen : 1;
+	/* Do all the ancestors extend their parent? */
+	guint			 all_ancestors_extend : 1;
+	/* Do not apply styles to children contexts */
+	guint			 ignore_children_style : 1;
+};
+
+struct _Segment
+{
+	Segment			*parent;
+	Segment			*next;
+	Segment			*prev;
+	Segment			*children;
+	Segment			*last_child;
+
+	/* This is NULL if and only if it's a dummy segment which denotes
+	 * inserted or deleted text. */
+	Context			*context;
+
+	/* Subpatterns found in this segment. */
+	SubPattern		*sub_patterns;
+
+	/* The context is used in the interval [start_at; end_at). */
+	gint			 start_at;
+	gint			 end_at;
+
+	/* In case of container contexts, start_len/end_len is length in chars
+	 * of start/end match. */
+	gint			 start_len;
+	gint			 end_len;
+
+	/* Whether this segment is a whole good segment, or it's an
+	 * an end of bigger one left after erase_segments() call. */
+	guint			 is_start : 1;
+};
+
+struct _SubPatternDefinition
+{
+#ifdef NEED_DEBUG_ID
+	/* We need the id only for debugging. */
+	gchar			*id;
+#endif
+	gchar			*style;
+	SubPatternWhere		 where;
+
+	/* List of class definitions */
+	GSList                  *context_classes;
+
+	/* index in the ContextDefinition's list */
+	guint			 index;
+
+	union
+	{
+		gint	 	 num;
+		gchar		*name;
+	} u;
+	guint			 is_named : 1;
+};
+
+struct _ContextDefinition
+{
+	gchar			*id;
+
+	ContextType		 type;
+	union
+	{
+		Regex		*match;
+		struct {
+			Regex	*start;
+			Regex	*end;
+		}		 start_end;
+	} u;
+
+	/* Name of the style used for contexts of this type. */
+	gchar			*default_style;
+
+	/* This is a list of DefinitionChild pointers. */
+	GSList			*children;
+
+	/* Sub patterns (list of SubPatternDefinition pointers.) */
+	GSList			*sub_patterns;
+	guint			 n_sub_patterns;
+
+	/* List of class definitions */
+	GSList			*context_classes;
+
+	/* Union of every regular expression we can find from this
+	 * context. */
+	Regex			*reg_all;
+
+	guint                    flags : 8;
+	guint                    ref_count : 24;
+};
+
+struct _SubPattern
+{
+	SubPatternDefinition	*definition;
+	gint			 start_at;
+	gint			 end_at;
+	SubPattern		*next;
+};
+#endif /* __GTK_SOURCE_CONTEXT_ENGINE_PRIVATE_H__ */
diff --git a/gtksourceview/gtksourcecontextengine.c b/gtksourceview/gtksourcecontextengine.c
index 4308254..24a36a1 100644
--- a/gtksourceview/gtksourcecontextengine.c
+++ b/gtksourceview/gtksourcecontextengine.c
@@ -21,10 +21,12 @@
 
 #include "gtksourceview-i18n.h"
 #include "gtksourcecontextengine.h"
+#include "gtksourcecontextengine-private.h"
 #include "gtktextregion.h"
 #include "gtksourcelanguage-private.h"
 #include "gtksourcebuffer.h"
 #include "gtksourcestyle-private.h"
+#include "gtksourceview-marshal.h"
 
 #include <glib.h>
 
@@ -83,7 +85,6 @@
 #define LOOKUP_DEFINITION(ctx_data, id) \
 	(g_hash_table_lookup ((ctx_data)->definitions, (id)))
 
-#define HAS_OPTION(def,opt) (((def)->flags & GTK_SOURCE_CONTEXT_##opt) != 0)
 
 /* Can the context be terminated by ancestor? */
 /* Root context can't be terminated; its child may not be terminated by it;
@@ -109,32 +110,12 @@
 	((ctx)->parent != NULL && HAS_OPTION ((ctx)->definition, END_AT_LINE_END))
 #define SEGMENT_END_AT_LINE_END(s) CONTEXT_END_AT_LINE_END((s)->context)
 
-#define CONTEXT_IS_SIMPLE(c) ((c)->definition->type == CONTEXT_TYPE_SIMPLE)
-#define CONTEXT_IS_CONTAINER(c) ((c)->definition->type == CONTEXT_TYPE_CONTAINER)
-#define SEGMENT_IS_INVALID(s) ((s)->context == NULL)
-#define SEGMENT_IS_SIMPLE(s) CONTEXT_IS_SIMPLE ((s)->context)
-#define SEGMENT_IS_CONTAINER(s) CONTEXT_IS_CONTAINER ((s)->context)
 
-#define ENGINE_ID(ce) ((ce)->priv->ctx_data->lang->priv->id)
-#define ENGINE_STYLES_MAP(ce) ((ce)->priv->ctx_data->lang->priv->styles)
 
 #define TAG_CONTEXT_CLASS_NAME "GtkSourceViewTagContextClassName"
 
-typedef struct _RegexInfo RegexInfo;
-typedef struct _RegexAndMatch RegexAndMatch;
-typedef struct _Regex Regex;
-typedef struct _SubPatternDefinition SubPatternDefinition;
-typedef struct _SubPattern SubPattern;
-typedef struct _Segment Segment;
-typedef struct _Context Context;
-typedef struct _ContextPtr ContextPtr;
-typedef struct _ContextDefinition ContextDefinition;
-typedef struct _DefinitionChild DefinitionChild;
-typedef struct _DefinitionsIter DefinitionsIter;
-typedef struct _LineInfo LineInfo;
-typedef struct _InvalidRegion InvalidRegion;
-typedef struct _ContextClassTag ContextClassTag;
-
+#define ENGINE_ID(ce) ((ce)->priv->ctx_data->lang->priv->id)
+#define ENGINE_STYLES_MAP(ce) ((ce)->priv->ctx_data->lang->priv->styles)
 typedef enum {
 	GTK_SOURCE_CONTEXT_ENGINE_ERROR_DUPLICATED_ID = 0,
 	GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_ARGS,
@@ -147,16 +128,12 @@ typedef enum {
 	GTK_SOURCE_CONTEXT_ENGINE_ERROR_BAD_FILE
 } GtkSourceContextEngineError;
 
-typedef enum {
-	CONTEXT_TYPE_SIMPLE = 0,
-	CONTEXT_TYPE_CONTAINER
-} ContextType;
+enum {
+	SIGNAL_TREE_UPDATED = 0,
+	SIGNAL_LAST
+};
 
-typedef enum {
-	SUB_PATTERN_WHERE_DEFAULT = 0,
-	SUB_PATTERN_WHERE_START,
-	SUB_PATTERN_WHERE_END
-} SubPatternWhere;
+static guint signals[SIGNAL_LAST];
 
 struct _RegexInfo
 {
@@ -182,63 +159,7 @@ struct _Regex
 	guint			 resolved : 1;
 };
 
-struct _ContextDefinition
-{
-	gchar			*id;
-
-	ContextType		 type;
-	union
-	{
-		Regex		*match;
-		struct {
-			Regex	*start;
-			Regex	*end;
-		}		 start_end;
-	} u;
-
-	/* Name of the style used for contexts of this type. */
-	gchar			*default_style;
-
-	/* This is a list of DefinitionChild pointers. */
-	GSList			*children;
-
-	/* Sub patterns (list of SubPatternDefinition pointers.) */
-	GSList			*sub_patterns;
-	guint			 n_sub_patterns;
-
-	/* List of class definitions */
-	GSList			*context_classes;
-
-	/* Union of every regular expression we can find from this
-	 * context. */
-	Regex			*reg_all;
-
-	guint                    flags : 8;
-	guint                    ref_count : 24;
-};
-
-struct _SubPatternDefinition
-{
-#ifdef NEED_DEBUG_ID
-	/* We need the id only for debugging. */
-	gchar			*id;
-#endif
-	gchar			*style;
-	SubPatternWhere		 where;
 
-	/* List of class definitions */
-	GSList                  *context_classes;
-
-	/* index in the ContextDefinition's list */
-	guint			 index;
-
-	union
-	{
-		gint	 	 num;
-		gchar		*name;
-	} u;
-	guint			 is_named : 1;
-};
 
 struct _DefinitionChild
 {
@@ -267,40 +188,7 @@ struct _DefinitionsIter
 	GSList			*children_stack;
 };
 
-struct _Context
-{
-	/* Definition for the context. */
-	ContextDefinition	*definition;
-
-	Context			*parent;
-	ContextPtr		*children;
-
-	/* This is the regex returned by regex_resolve() called on
-	 * definition->start_end.end. */
-	Regex			*end;
-	/* The regular expression containing every regular expression that
-	 * could be matched in this context. */
-	Regex			*reg_all;
 
-	/* Either definition->default_style or child_def->style, not copied. */
-	const gchar		*style;
-	GtkTextTag		*tag;
-	GtkTextTag	       **subpattern_tags;
-
-	/* Cache for generated list of class tags */
-	GSList                  *context_classes;
-
-	/* Cache for generated list of subpattern class tags */
-	GSList                 **subpattern_context_classes;
-
-	guint			 ref_count;
-	/* see context_freeze() */
-	guint                    frozen : 1;
-	/* Do all the ancestors extend their parent? */
-	guint			 all_ancestors_extend : 1;
-	/* Do not apply styles to children contexts */
-	guint			 ignore_children_style : 1;
-};
 
 struct _ContextPtr
 {
@@ -321,42 +209,7 @@ struct _GtkSourceContextReplace
 	gchar			*replace_with;
 };
 
-struct _Segment
-{
-	Segment			*parent;
-	Segment			*next;
-	Segment			*prev;
-	Segment			*children;
-	Segment			*last_child;
-
-	/* This is NULL if and only if it's a dummy segment which denotes
-	 * inserted or deleted text. */
-	Context			*context;
-
-	/* Subpatterns found in this segment. */
-	SubPattern		*sub_patterns;
-
-	/* The context is used in the interval [start_at; end_at). */
-	gint			 start_at;
-	gint			 end_at;
-
-	/* In case of container contexts, start_len/end_len is length in chars
-	 * of start/end match. */
-	gint			 start_len;
-	gint			 end_len;
 
-	/* Whether this segment is a whole good segment, or it's an
-	 * an end of bigger one left after erase_segments() call. */
-	guint			 is_start : 1;
-};
-
-struct _SubPattern
-{
-	SubPatternDefinition	*definition;
-	gint			 start_at;
-	gint			 end_at;
-	SubPattern		*next;
-};
 
 /* Line terminator characters (\n, \r, \r\n, or unicode paragraph separator)
  * are removed from the line text. The problem is that pcre does not understand
@@ -400,17 +253,6 @@ struct _InvalidRegion
 	gint			 delta;
 };
 
-struct _GtkSourceContextClass
-{
-	gchar    *name;
-	gboolean  enabled;
-};
-
-struct _ContextClassTag
-{
-	GtkTextTag *tag;
-	gboolean enabled;
-};
 
 struct _GtkSourceContextData
 {
@@ -427,23 +269,16 @@ struct _GtkSourceContextEnginePrivate
 	GtkSourceContextData	*ctx_data;
 
 	GtkTextBuffer		*buffer;
-	GtkSourceStyleScheme	*style_scheme;
-
-	/* All tags indexed by style name: values are GSList's of tags, ref()'ed. */
-	GHashTable		*tags;
-	/* Number of all syntax tags created by the engine, needed to set correct
-	 * tag priorities */
-	guint			 n_tags;
 
 	GHashTable		*context_classes;
 
-	/* Whether or not to actually highlight the buffer. */
-	gboolean		 highlight;
+	/* Whether or not to actually analyze the syntax of the buffer. */
+	gboolean		 analyze_syntax;
 
-	/* Whether highlighting was disabled because of errors. */
+	/* Whether Syntax analysis was disabled because of errors. */
 	gboolean		 disabled;
 
-	/* Region covering the unhighlighted text. */
+	/* Region covering the non-analyzed text. */
 	GtkTextRegion		*refresh_region;
 
 	/* Tree of contexts. */
@@ -588,405 +423,9 @@ context_class_tag_free (ContextClassTag *attrtag)
 	g_slice_free (ContextClassTag, attrtag);
 }
 
-struct BufAndIters {
-	GtkTextBuffer *buffer;
-	const GtkTextIter *start, *end;
-};
-
-static void
-unhighlight_region_cb (G_GNUC_UNUSED gpointer style,
-		       GSList   *tags,
-		       gpointer  user_data)
-{
-	struct BufAndIters *data = user_data;
-
-	while (tags != NULL)
-	{
-		gtk_text_buffer_remove_tag (data->buffer,
-					    tags->data,
-					    data->start,
-					    data->end);
-		tags = tags->next;
-	}
-}
-
-static void
-unhighlight_region (GtkSourceContextEngine *ce,
-		    const GtkTextIter      *start,
-		    const GtkTextIter      *end)
-{
-	struct BufAndIters data;
-
-	data.buffer = ce->priv->buffer;
-	data.start = start;
-	data.end = end;
-
-	if (gtk_text_iter_equal (start, end))
-		return;
-
-	g_hash_table_foreach (ce->priv->tags, (GHFunc) unhighlight_region_cb, &data);
-}
 
 #define MAX_STYLE_DEPENDENCY_DEPTH	50
 
-static void
-set_tag_style (GtkSourceContextEngine *ce,
-	       GtkTextTag             *tag,
-	       const gchar            *style_id)
-{
-	GtkSourceStyle *style;
-
-	const char *map_to = style_id;
-
-	int guard = 0;
-
-	g_return_if_fail (GTK_IS_TEXT_TAG (tag));
-	g_return_if_fail (style_id != NULL);
-
-	_gtk_source_style_apply (NULL, tag);
-
-	if (ce->priv->style_scheme == NULL)
-		return;
-
-	style = gtk_source_style_scheme_get_style (ce->priv->style_scheme, style_id);
-
-	while (style == NULL)
-	{
-		GtkSourceStyleInfo *info;
-
-		if (guard > MAX_STYLE_DEPENDENCY_DEPTH)
-		{
-			g_warning ("Potential circular dependency between styles detected for style '%s'", style_id);
-			break;
-		}
-
-		++guard;
-
-		/* FIXME Style references really must be fixed, both parser for
-		 * sane use in lang files, and engine for safe use. */
-		info = g_hash_table_lookup (ENGINE_STYLES_MAP(ce), map_to);
-
-		map_to = (info != NULL) ? info->map_to : NULL;
-
-		if (!map_to)
-			break;
-
-		style = gtk_source_style_scheme_get_style (ce->priv->style_scheme, map_to);
-	}
-
-	/* not having style is fine, since parser checks validity of every style reference,
-	 * so we don't need to spit a warning here */
-	if (style != NULL)
-		_gtk_source_style_apply (style, tag);
-}
-
-static GtkTextTag *
-create_tag (GtkSourceContextEngine *ce,
-	    const gchar            *style_id)
-{
-	GSList *tags;
-	GtkTextTag *new_tag;
-
-	g_assert (style_id != NULL);
-
-	tags = g_hash_table_lookup (ce->priv->tags, style_id);
-
-	new_tag = gtk_text_buffer_create_tag (ce->priv->buffer, NULL, NULL);
-	/* It must have priority lower than user tags but still
-	 * higher than highlighting tags created before */
-	gtk_text_tag_set_priority (new_tag, ce->priv->n_tags);
-	set_tag_style (ce, new_tag, style_id);
-	ce->priv->n_tags += 1;
-
-	tags = g_slist_prepend (tags, g_object_ref (new_tag));
-	g_hash_table_insert (ce->priv->tags, g_strdup (style_id), tags);
-
-	return new_tag;
-}
-
-/* Find tag which has to be overridden. */
-static GtkTextTag *
-get_parent_tag (Context    *context,
-		const char *style)
-{
-	while (context != NULL)
-	{
-		/* Lang files may repeat same style for nested contexts,
-		 * ignore them. */
-		if (context->style &&
-		    strcmp (context->style, style) != 0)
-		{
-			g_assert (context->tag != NULL);
-			return context->tag;
-		}
-
-		context = context->parent;
-	}
-
-	return NULL;
-}
-
-static GtkTextTag *
-get_tag_for_parent (GtkSourceContextEngine *ce,
-		    const char             *style,
-		    Context                *parent)
-{
-	GSList *tags;
-	GtkTextTag *parent_tag = NULL;
-	GtkTextTag *tag;
-
-	g_return_val_if_fail (style != NULL, NULL);
-
-	parent_tag = get_parent_tag (parent, style);
-	tags = g_hash_table_lookup (ce->priv->tags, style);
-
-	if (tags && (!parent_tag ||
-		gtk_text_tag_get_priority (tags->data) > gtk_text_tag_get_priority (parent_tag)))
-	{
-		GSList *link;
-
-		tag = tags->data;
-
-		/* Now get the tag with lowest priority, so that tag lists do not grow
-		 * indefinitely. */
-		for (link = tags->next; link != NULL; link = link->next)
-		{
-			if (parent_tag &&
-			    gtk_text_tag_get_priority (link->data) < gtk_text_tag_get_priority (parent_tag))
-				break;
-			tag = link->data;
-		}
-	}
-	else
-	{
-		tag = create_tag (ce, style);
-
-#ifdef ENABLE_DEBUG
-		{
-			GString *style_path = g_string_new (style);
-			gint n;
-
-			while (parent != NULL)
-			{
-				if (parent->style != NULL)
-				{
-					g_string_prepend (style_path, "/");
-					g_string_prepend (style_path,
-							  parent->style);
-				}
-
-				parent = parent->parent;
-			}
-
-			tags = g_hash_table_lookup (ce->priv->tags, style);
-			n = g_slist_length (tags);
-			g_print ("created %d tag for style %s: %s\n", n, style, style_path->str);
-			g_string_free (style_path, TRUE);
-		}
-#endif
-	}
-
-	return tag;
-}
-
-static GtkTextTag *
-get_subpattern_tag (GtkSourceContextEngine *ce,
-		    Context                *context,
-		    SubPatternDefinition   *sp_def)
-{
-	if (sp_def->style == NULL)
-		return NULL;
-
-	g_assert (sp_def->index < context->definition->n_sub_patterns);
-
-	if (context->subpattern_tags == NULL)
-		context->subpattern_tags = g_new0 (GtkTextTag*, context->definition->n_sub_patterns);
-
-	if (context->subpattern_tags[sp_def->index] == NULL)
-		context->subpattern_tags[sp_def->index] = get_tag_for_parent (ce, sp_def->style, context);
-
-	g_return_val_if_fail (context->subpattern_tags[sp_def->index] != NULL, NULL);
-	return context->subpattern_tags[sp_def->index];
-}
-
-static GtkTextTag *
-get_context_tag (GtkSourceContextEngine *ce,
-		 Context                *context)
-{
-	if (context->style != NULL && context->tag == NULL)
-		context->tag = get_tag_for_parent (ce,
-						   context->style,
-						   context->parent);
-	return context->tag;
-}
-
-static void
-apply_tags (GtkSourceContextEngine *ce,
-	    Segment                *segment,
-	    gint                    start_offset,
-	    gint                    end_offset)
-{
-	GtkTextTag *tag;
-	GtkTextIter start_iter, end_iter;
-	GtkTextBuffer *buffer = ce->priv->buffer;
-	SubPattern *sp;
-	Segment *child;
-
-	g_assert (segment != NULL);
-
-	if (SEGMENT_IS_INVALID (segment))
-		return;
-
-	if (segment->start_at >= end_offset || segment->end_at <= start_offset)
-		return;
-
-	start_offset = MAX (start_offset, segment->start_at);
-	end_offset = MIN (end_offset, segment->end_at);
-
-	tag = get_context_tag (ce, segment->context);
-
-	if (tag != NULL)
-	{
-		gint style_start_at, style_end_at;
-
-		style_start_at = start_offset;
-		style_end_at = end_offset;
-
-		if (HAS_OPTION (segment->context->definition, STYLE_INSIDE))
-		{
-			style_start_at = MAX (segment->start_at + segment->start_len, start_offset);
-			style_end_at = MIN (segment->end_at - segment->end_len, end_offset);
-		}
-
-		if (style_start_at > style_end_at)
-		{
-			g_critical ("%s: oops", G_STRLOC);
-		}
-		else
-		{
-			gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, style_start_at);
-			end_iter = start_iter;
-			gtk_text_iter_forward_chars (&end_iter, style_end_at - style_start_at);
-			gtk_text_buffer_apply_tag (ce->priv->buffer, tag, &start_iter, &end_iter);
-		}
-	}
-
-	for (sp = segment->sub_patterns; sp != NULL; sp = sp->next)
-	{
-		if (sp->start_at >= start_offset && sp->end_at <= end_offset)
-		{
-			gint start = MAX (start_offset, sp->start_at);
-			gint end = MIN (end_offset, sp->end_at);
-
-			tag = get_subpattern_tag (ce, segment->context, sp->definition);
-
-			if (tag != NULL)
-			{
-				gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, start);
-				end_iter = start_iter;
-				gtk_text_iter_forward_chars (&end_iter, end - start);
-				gtk_text_buffer_apply_tag (ce->priv->buffer, tag, &start_iter, &end_iter);
-			}
-		}
-	}
-
-	for (child = segment->children;
-	     child != NULL && child->start_at < end_offset;
-	     child = child->next)
-	{
-		if (child->end_at > start_offset)
-			apply_tags (ce, child, start_offset, end_offset);
-	}
-}
-
-/**
- * highlight_region:
- *
- * @ce: a #GtkSourceContextEngine.
- * @start: the beginning of the region to highlight.
- * @end: the end of the region to highlight.
- *
- * Highlights the specified region.
- */
-static void
-highlight_region (GtkSourceContextEngine *ce,
-		  GtkTextIter            *start,
-		  GtkTextIter            *end)
-{
-#ifdef ENABLE_PROFILE
-	GTimer *timer;
-#endif
-
-	if (gtk_text_iter_starts_line (end))
-		gtk_text_iter_backward_char (end);
-	if (gtk_text_iter_compare (start, end) >= 0)
-		return;
-
-#ifdef ENABLE_PROFILE
-	timer = g_timer_new ();
-#endif
-
-	/* First we need to delete tags in the regions. */
-	unhighlight_region (ce, start, end);
-
-	apply_tags (ce, ce->priv->root_segment,
-		    gtk_text_iter_get_offset (start),
-		    gtk_text_iter_get_offset (end));
-
-#ifdef ENABLE_PROFILE
-	g_print ("highlight (from %d to %d), %g ms elapsed\n",
-		 gtk_text_iter_get_offset (start),
-		 gtk_text_iter_get_offset (end),
-		 g_timer_elapsed (timer, NULL) * 1000);
-	g_timer_destroy (timer);
-#endif
-}
-
-/**
- * ensure_highlighted:
- *
- * @ce: a #GtkSourceContextEngine.
- * @start: the beginning of the region to highlight.
- * @end: the end of the region to highlight.
- *
- * Updates text tags in reanalyzed parts of given area.
- * It applies tags according to whatever is in the syntax
- * tree currently, so highlighting may not be correct
- * (gtk_source_context_engine_update_highlight is the method
- * that actually ensures correct highlighting).
- */
-static void
-ensure_highlighted (GtkSourceContextEngine *ce,
-		    const GtkTextIter      *start,
-		    const GtkTextIter      *end)
-{
-	GtkTextRegion *region;
-	GtkTextRegionIterator reg_iter;
-
-	/* Get the subregions not yet highlighted. */
-	region = gtk_text_region_intersect (ce->priv->refresh_region, start, end);
-
-	if (region == NULL)
-		return;
-
-	gtk_text_region_get_iterator (region, &reg_iter, 0);
-
-	/* Highlight all subregions from the intersection.
-	 * hopefully this will only be one subregion. */
-	while (!gtk_text_region_iterator_is_end (&reg_iter))
-	{
-		GtkTextIter s, e;
-		gtk_text_region_iterator_get_subregion (&reg_iter, &s, &e);
-		highlight_region (ce, &s, &e);
-		gtk_text_region_iterator_next (&reg_iter);
-	}
-
-	gtk_text_region_destroy (region, TRUE);
-
-	/* Remove the just highlighted region. */
-	gtk_text_region_subtract (ce->priv->refresh_region, start, end);
-}
-
 static GtkTextTag *
 get_context_class_tag (GtkSourceContextEngine *ce,
                        gchar const            *name)
@@ -1277,11 +716,12 @@ refresh_range (GtkSourceContextEngine *ce,
 		/* I don't quite like this here, but at least it won't jump into
 		 * the middle of \r\n  */
 		gtk_text_iter_backward_cursor_position (&real_end);
-
+	printf("Emitting highlight_updated signal. %p = \n", ce->priv->root_segment);
 	g_signal_emit_by_name (ce->priv->buffer,
 			       "highlight_updated",
 			       start,
 			       &real_end);
+			      // ce->priv->refresh_region);
 }
 
 
@@ -2271,7 +1711,7 @@ update_tree (GtkSourceContextEngine *ce)
 }
 
 /**
- * gtk_source_context_engine_update_highlight:
+ * gtk_source_context_engine_update:
  *
  * @ce: a #GtkSourceContextEngine.
  * @start: start of area to update.
@@ -2279,22 +1719,22 @@ update_tree (GtkSourceContextEngine *ce)
  * @synchronous: whether it should block until everything
  * is analyzed/highlighted.
  *
- * GtkSourceEngine::update_highlight method.
+ * GtkSourceEngine::update method.
  *
- * Makes sure the area is analyzed and highlighted. If @asynchronous
+ * Makes sure the area is analyzed. If @synchronous
  * is %FALSE, then it queues idle worker.
  */
 static void
-gtk_source_context_engine_update_highlight (GtkSourceEngine   *engine,
-					    const GtkTextIter *start,
-					    const GtkTextIter *end,
-					    gboolean           synchronous)
+gtk_source_context_engine_update (GtkSourceEngine   *engine,
+				  const GtkTextIter *start,
+				  const GtkTextIter *end,
+				  gboolean           synchronous)
 {
 	gint invalid_line;
 	gint end_line;
 	GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (engine);
 
-	if (!ce->priv->highlight || ce->priv->disabled)
+	if (!ce->priv->analyze_syntax || ce->priv->disabled)
 		return;
 
 	invalid_line = get_invalid_line (ce);
@@ -2305,13 +1745,13 @@ gtk_source_context_engine_update_highlight (GtkSourceEngine   *engine,
 
 	if (invalid_line < 0 || invalid_line > end_line)
 	{
-		ensure_highlighted (ce, start, end);
+		/* The region is already analyzed */
+		return;
 	}
 	else if (synchronous)
 	{
 		/* analyze whole region */
 		update_syntax (ce, end, 0);
-		ensure_highlighted (ce, start, end);
 	}
 	else
 	{
@@ -2323,7 +1763,6 @@ gtk_source_context_engine_update_highlight (GtkSourceEngine   *engine,
 		{
 			GtkTextIter valid_end = *start;
 			gtk_text_iter_set_line (&valid_end, invalid_line);
-			ensure_highlighted (ce, start, &valid_end);
 			gtk_text_region_add (ce->priv->highlight_requests, &valid_end, end);
 		}
 
@@ -2331,43 +1770,6 @@ gtk_source_context_engine_update_highlight (GtkSourceEngine   *engine,
 	}
 }
 
-/**
- * enable_highlight:
- *
- * @ce: a #GtkSourceContextEngine.
- * @enable: whether to enable highlighting.
- *
- * Whether to highlight (i.e. apply tags) analyzed area.
- * Note that this does not turn on/off the analyzis stuff,
- * it affects only text tags.
- */
-static void
-enable_highlight (GtkSourceContextEngine *ce,
-		  gboolean                enable)
-{
-	GtkTextIter start, end;
-
-	if (!enable == !ce->priv->highlight)
-		return;
-
-	ce->priv->highlight = enable != 0;
-	gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (ce->priv->buffer),
-				    &start, &end);
-
-	if (enable)
-		refresh_range (ce, &start, &end, TRUE);
-	else
-		unhighlight_region (ce, &start, &end);
-}
-
-static void
-buffer_notify_highlight_syntax_cb (GtkSourceContextEngine *ce)
-{
-	gboolean highlight;
-	g_object_get (ce->priv->buffer, "highlight-syntax", &highlight, NULL);
-	enable_highlight (ce, highlight);
-}
-
 
 /* IDLE WORKER CODE ------------------------------------------------------- */
 
@@ -2432,6 +1834,7 @@ first_update_callback (GtkSourceContextEngine *ce)
 	gdk_threads_enter ();
 
 	/* analyze batch of text */
+	printf("UPDATING SYNTAX\n");
 	update_syntax (ce, NULL, FIRST_UPDATE_TIME_SLICE);
 	CHECK_TREE (ce);
 
@@ -2502,23 +1905,6 @@ gtk_source_context_engine_error_quark (void)
 }
 
 static void
-remove_tags_hash_cb (G_GNUC_UNUSED gpointer style,
-		     GSList          *tags,
-		     GtkTextTagTable *table)
-{
-	GSList *l = tags;
-
-	while (l != NULL)
-	{
-		gtk_text_tag_table_remove (table, l->data);
-		g_object_unref (l->data);
-		l = l->next;
-	}
-
-	g_slist_free (tags);
-}
-
-static void
 remove_context_classes_hash_cb (G_GNUC_UNUSED gpointer class,
                                 GtkTextTag             *tag,
                                 GtkTextTagTable        *table)
@@ -2526,22 +1912,6 @@ remove_context_classes_hash_cb (G_GNUC_UNUSED gpointer class,
 	gtk_text_tag_table_remove (table, tag);
 }
 
-/**
- * destroy_tags_hash:
- *
- * @ce: #GtkSourceContextEngine.
- *
- * Destroys syntax tags cache.
- */
-static void
-destroy_tags_hash (GtkSourceContextEngine *ce)
-{
-	g_hash_table_foreach (ce->priv->tags, (GHFunc) remove_tags_hash_cb,
-                              gtk_text_buffer_get_tag_table (ce->priv->buffer));
-	g_hash_table_destroy (ce->priv->tags);
-	ce->priv->tags = NULL;
-}
-
 static void
 destroy_context_classes_hash (GtkSourceContextEngine *ce)
 {
@@ -2574,9 +1944,6 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
 	/* Detach previous buffer if there is one. */
 	if (ce->priv->buffer != NULL)
 	{
-		g_signal_handlers_disconnect_by_func (ce->priv->buffer,
-						      (gpointer) buffer_notify_highlight_syntax_cb,
-						      ce);
 
 		if (ce->priv->first_update != 0)
 			g_source_remove (ce->priv->first_update);
@@ -2604,15 +1971,6 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
 		ce->priv->invalid_region.start = NULL;
 		ce->priv->invalid_region.end = NULL;
 
-		/* this deletes tags from the tag table, therefore there is no need
-		 * in removing tags from the text (it may be very slow).
-		 * FIXME: don't we want to just destroy and forget everything when
-		 * the buffer is destroyed? Removing tags is still slower than doing
-		 * nothing. Caveat: if tag table is shared with other buffer, we do
-		 * need to remove tags. */
-		destroy_tags_hash (ce);
-		ce->priv->n_tags = 0;
-
 		destroy_context_classes_hash (ce);
 
 		if (ce->priv->refresh_region != NULL)
@@ -2643,7 +2001,6 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
 		ce->priv->root_context = context_new (NULL, main_definition, NULL, NULL, FALSE);
 		ce->priv->root_segment = create_segment (ce, NULL, ce->priv->root_context, 0, 0, TRUE, NULL);
 
-		ce->priv->tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 		ce->priv->context_classes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
 		gtk_text_buffer_get_bounds (buffer, &start, &end);
@@ -2663,21 +2020,16 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
 			ce->priv->invalid_region.delta = 0;
 		}
 
-		g_object_get (ce->priv->buffer, "highlight-syntax", &ce->priv->highlight, NULL);
+		g_object_get (ce->priv->buffer, "analyze-syntax", &ce->priv->analyze_syntax, NULL);
 		ce->priv->refresh_region = gtk_text_region_new (buffer);
 		ce->priv->highlight_requests = gtk_text_region_new (buffer);
 
-		g_signal_connect_swapped (buffer,
-					  "notify::highlight-syntax",
-					  G_CALLBACK (buffer_notify_highlight_syntax_cb),
-					  ce);
-
 		install_first_update (ce);
 	}
 }
 
 /**
- * disable_highlighting:
+ * disable_syntax_analysis:
  *
  * @ce: #GtkSourceContextEngine.
  *
@@ -2686,7 +2038,7 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
  * text editor).
  */
 static void
-disable_highlighting (GtkSourceContextEngine *ce)
+disable_syntax_analysis (GtkSourceContextEngine *ce)
 {
 	if (!ce->priv->disabled)
 	{
@@ -2697,48 +2049,6 @@ disable_highlighting (GtkSourceContextEngine *ce)
 }
 
 static void
-set_tag_style_hash_cb (const char             *style,
-		       GSList                 *tags,
-		       GtkSourceContextEngine *ce)
-{
-	while (tags != NULL)
-	{
-		set_tag_style (ce, tags->data, style);
-		tags = tags->next;
-	}
-}
-
-/**
- * gtk_source_context_engine_set_style_scheme:
- *
- * @engine: #GtkSourceContextEngine.
- * @scheme: #GtkSourceStyleScheme to set.
- *
- * GtkSourceEngine::set_style_scheme method.
- * Sets current style scheme, updates tag styles and everything.
- */
-static void
-gtk_source_context_engine_set_style_scheme (GtkSourceEngine      *engine,
-					    GtkSourceStyleScheme *scheme)
-{
-	GtkSourceContextEngine *ce;
-
-	g_return_if_fail (GTK_IS_SOURCE_CONTEXT_ENGINE (engine));
-	g_return_if_fail (GTK_IS_SOURCE_STYLE_SCHEME (scheme) || scheme == NULL);
-
-	ce = GTK_SOURCE_CONTEXT_ENGINE (engine);
-
-	if (scheme == ce->priv->style_scheme)
-		return;
-
-	if (ce->priv->style_scheme != NULL)
-		g_object_unref (ce->priv->style_scheme);
-
-	ce->priv->style_scheme = scheme ? g_object_ref (scheme) : NULL;
-	g_hash_table_foreach (ce->priv->tags, (GHFunc) set_tag_style_hash_cb, ce);
-}
-
-static void
 gtk_source_context_engine_finalize (GObject *object)
 {
 	GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (object);
@@ -2756,7 +2066,6 @@ gtk_source_context_engine_finalize (GObject *object)
 		g_source_remove (ce->priv->mem_usage_timeout);
 #endif
 
-	g_assert (!ce->priv->tags);
 	g_assert (!ce->priv->root_context);
 	g_assert (!ce->priv->root_segment);
 	g_assert (!ce->priv->first_update);
@@ -2764,8 +2073,6 @@ gtk_source_context_engine_finalize (GObject *object)
 
 	_gtk_source_context_data_unref (ce->priv->ctx_data);
 
-	if (ce->priv->style_scheme != NULL)
-		g_object_unref (ce->priv->style_scheme);
 
 	G_OBJECT_CLASS (_gtk_source_context_engine_parent_class)->finalize (object);
 }
@@ -2797,11 +2104,11 @@ _gtk_source_context_engine_class_init (GtkSourceContextEngineClass *klass)
 	engine_class->attach_buffer = gtk_source_context_engine_attach_buffer;
 	engine_class->text_inserted = gtk_source_context_engine_text_inserted;
 	engine_class->text_deleted = gtk_source_context_engine_text_deleted;
-	engine_class->update_highlight = gtk_source_context_engine_update_highlight;
-	engine_class->set_style_scheme = gtk_source_context_engine_set_style_scheme;
+	engine_class->update = gtk_source_context_engine_update;
 	engine_class->get_context_class_tag = gtk_source_context_engine_get_context_class_tag;
 
 	g_type_class_add_private (object_class, sizeof (GtkSourceContextEnginePrivate));
+
 }
 
 static void
@@ -2811,6 +2118,14 @@ _gtk_source_context_engine_init (GtkSourceContextEngine *ce)
 						GtkSourceContextEnginePrivate);
 }
 
+Segment *
+_gtk_source_context_engine_get_tree (GtkSourceContextEngine *ce)
+{
+	if (ce)
+		return ce->priv->root_segment;
+	else
+		return NULL;
+}
 GtkSourceContextEngine *
 _gtk_source_context_engine_new (GtkSourceContextData *ctx_data)
 {
@@ -2822,6 +2137,8 @@ _gtk_source_context_engine_new (GtkSourceContextData *ctx_data)
 	ce = g_object_new (GTK_TYPE_SOURCE_CONTEXT_ENGINE, NULL);
 	ce->priv->ctx_data = _gtk_source_context_data_ref (ctx_data);
 
+
+
 #ifdef ENABLE_MEMORY_DEBUG
 	ce->priv->mem_usage_timeout =
 		g_timeout_add (5000, (GSourceFunc) mem_usage_timeout, ce);
@@ -4939,7 +4256,7 @@ analyze_line (GtkSourceContextEngine *ce,
 			g_critical ("%s",
 			            _("Highlighting a single line took too much time, "
 				      "syntax highlighting will be disabled"));
-			disable_highlighting (ce);
+			disable_syntax_analysis (ce);
 			break;
 		}
 
@@ -6018,6 +5335,8 @@ update_syntax (GtkSourceContextEngine *ce,
 
 	g_timer_destroy (timer);
 
+	printf("Syntax updated\n");
+
 out:
 	/* must call context_thaw, so this is the only return point */
 	context_thaw (ce->priv->root_context);
diff --git a/gtksourceview/gtksourcecontextengine.h b/gtksourceview/gtksourcecontextengine.h
index 5074000..0dbedf8 100644
--- a/gtksourceview/gtksourcecontextengine.h
+++ b/gtksourceview/gtksourcecontextengine.h
@@ -24,6 +24,7 @@
 
 #include <gtksourceview/gtksourceengine.h>
 #include <gtksourceview/gtksourcelanguage.h>
+#include "gtksourcecontextengine-private.h"
 
 G_BEGIN_DECLS
 
@@ -83,6 +84,9 @@ void		gtk_source_context_class_free		(GtkSourceContextClass *cclass);
 
 GtkSourceContextEngine *_gtk_source_context_engine_new  (GtkSourceContextData	*data);
 
+Segment *		_gtk_source_context_engine_get_tree 
+							(GtkSourceContextEngine *ce);
+
 gboolean	 _gtk_source_context_data_define_context
 							(GtkSourceContextData	 *data,
 							 const gchar		 *id,
diff --git a/gtksourceview/gtksourceengine.c b/gtksourceview/gtksourceengine.c
index e89dfe2..094fb75 100644
--- a/gtksourceview/gtksourceengine.c
+++ b/gtksourceview/gtksourceengine.c
@@ -79,30 +79,19 @@ _gtk_source_engine_text_deleted (GtkSourceEngine *engine,
 }
 
 void
-_gtk_source_engine_update_highlight (GtkSourceEngine   *engine,
-				     const GtkTextIter *start,
-				     const GtkTextIter *end,
-				     gboolean           synchronous)
+_gtk_source_engine_update (GtkSourceEngine   *engine,
+			   const GtkTextIter *start,
+			   const GtkTextIter *end,
+			   gboolean           synchronous)
 {
 	g_return_if_fail (GTK_IS_SOURCE_ENGINE (engine));
 	g_return_if_fail (start != NULL && end != NULL);
-	g_return_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->update_highlight != NULL);
+	g_return_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->update != NULL);
 
-	GTK_SOURCE_ENGINE_GET_CLASS (engine)->update_highlight (engine,
-								start,
-								end,
-								synchronous);
-}
-
-void
-_gtk_source_engine_set_style_scheme (GtkSourceEngine      *engine,
-				     GtkSourceStyleScheme *scheme)
-{
-	g_return_if_fail (GTK_IS_SOURCE_ENGINE (engine));
-	g_return_if_fail (GTK_IS_SOURCE_STYLE_SCHEME (scheme) || scheme == NULL);
-	g_return_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->set_style_scheme != NULL);
-
-	GTK_SOURCE_ENGINE_GET_CLASS (engine)->set_style_scheme (engine, scheme);
+	GTK_SOURCE_ENGINE_GET_CLASS (engine)->update (engine,
+						      start,
+						      end,
+						      synchronous);
 }
 
 GtkTextTag *
diff --git a/gtksourceview/gtksourceengine.h b/gtksourceview/gtksourceengine.h
index 2768ffa..b58e970 100644
--- a/gtksourceview/gtksourceengine.h
+++ b/gtksourceview/gtksourceengine.h
@@ -56,14 +56,11 @@ struct _GtkSourceEngineClass
 				       gint                  offset,
 				       gint                  length);
 
-	void     (* update_highlight) (GtkSourceEngine      *engine,
+	void     (* update) 	      (GtkSourceEngine      *engine,
 				       const GtkTextIter    *start,
 				       const GtkTextIter    *end,
 				       gboolean              synchronous);
 
-	void     (* set_style_scheme) (GtkSourceEngine      *engine,
-				       GtkSourceStyleScheme *scheme);
-
 	GtkTextTag *(* get_context_class_tag)
 				      (GtkSourceEngine      *engine,
 				       const gchar          *context_class);
@@ -79,13 +76,10 @@ void        _gtk_source_engine_text_inserted	(GtkSourceEngine      *engine,
 void        _gtk_source_engine_text_deleted	(GtkSourceEngine      *engine,
 						 gint                  offset,
 						 gint                  length);
-void        _gtk_source_engine_update_highlight	(GtkSourceEngine      *engine,
+void        _gtk_source_engine_update		(GtkSourceEngine      *engine,
 						 const GtkTextIter    *start,
 						 const GtkTextIter    *end,
 						 gboolean              synchronous);
-void        _gtk_source_engine_set_style_scheme	(GtkSourceEngine      *engine,
-						 GtkSourceStyleScheme *scheme);
-
 GtkTextTag *_gtk_source_engine_get_context_class_tag
 						 (GtkSourceEngine     *engine,
 						  const gchar         *context_class);
diff --git a/gtksourceview/gtksourceview-marshal.list b/gtksourceview/gtksourceview-marshal.list
index e2ffb4b..85e2a01 100644
--- a/gtksourceview/gtksourceview-marshal.list
+++ b/gtksourceview/gtksourceview-marshal.list
@@ -13,3 +13,4 @@ VOID:ENUM,INT
 VOID:OBJECT,BOXED,POINTER
 BOOL:OBJECT,BOXED,OBJECT
 VOID:BOXED,POINTER
+VOID:BOXED,BOXED,POINTER
