diff --git a/configure.ac b/configure.ac
index 230543c..5ff6ae1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,7 +37,6 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE([enable])
 
 # Initialize libtool
-AC_PROG_LIBTOOL
 LT_PREREQ([2.2])
 LT_INIT([disable-static])
 
diff --git a/glamor.pc.in b/glamor.pc.in
index 74ecd2e..5257468 100644
--- a/glamor.pc.in
+++ b/glamor.pc.in
@@ -2,12 +2,11 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
 includedir=@includedir@
-moduledir=@moduledir@
 sdkdir=@sdkdir@
 GLAMOR_GL_CFLAGS=@GLAMOR_GL_CFLAGS@
 
 Name: glamor
 Description: X.Org glamor common library.
 Version: @PACKAGE_VERSION@
-Cflags: -I${sdkdir} -L${moduledir} -lglamor ${GLAMOR_GL_CFLAGS}
-
+Cflags: -I${sdkdir} ${GLAMOR_GL_CFLAGS}
+Libs: -L${libdir} -lglamor
diff --git a/src/Makefile.am b/src/Makefile.am
index 766aac7..4beb559 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-inst_LTLIBRARIES = libglamor.la
+lib_LTLIBRARIES = libglamor.la
 
 # Override these since glamor doesn't need them and the needed files aren't
 # built (in hw/xfree86/os-support/solaris) until after glamor is built
@@ -10,23 +10,26 @@ else
 libglamor_la_LIBADD = $(GL_LIBS)
 endif
 
-instdir = $(moduledir)
-
-INCLUDES = \
+AM_CPPFLAGS = \
 	$(XORG_INCS)
 
 AM_CFLAGS = $(CWARNFLAGS) $(XORG_CFLAGS) $(DIX_CFLAGS) $(LIBDRM_CFLAGS)
 
-libglamor_la_LDFLAGS = -avoid-version
+libglamor_la_LDFLAGS = -version-info 0:0:0
 
 libglamor_la_SOURCES = \
+	compat-api.h \
+	compiler.h \
 	glamor.c \
 	glamor_copyarea.c \
 	glamor_copywindow.c \
 	glamor_core.c \
+	glamor_debug.h \
+	glamor_gl_dispatch.h \
 	glamor_fill.c \
 	glamor_fillspans.c \
 	glamor_getspans.c \
+	glamor_glext.h \
 	glamor_glyphs.c \
 	glamor_polyfillrect.c \
 	glamor_polylines.c \
@@ -42,6 +45,7 @@ libglamor_la_SOURCES = \
 	glamor_copyplane.c\
 	glamor_glyphblt.c\
 	glamor_polyops.c\
+	glamor_priv.h\
 	glamor_pixmap.c\
 	glamor_largepixmap.c\
 	glamor_picture.c\
@@ -49,7 +53,9 @@ libglamor_la_SOURCES = \
 	glamor_gl_dispatch.c\
 	glamor_fbo.c\
 	glamor_compositerects.c\
-	glamor.h
+	glamor_utils.h\
+	glamor.h\
+	glapi.h
 
 sdk_HEADERS = glamor.h
 
@@ -57,7 +63,8 @@ if EGL
 LIBGLAMOREGL = libglamoregl.la
 module_LTLIBRARIES = $(LIBGLAMOREGL)
 libglamoregl_la_DEPENDENCIES = libglamor.la
-libglamoregl_la_LDFLAGS = -avoid-version -module $(EGL_LIBS) -lglamor $(GLX_SYS_LIBS)
+libglamoregl_la_LDFLAGS = -avoid-version -module
+libglamoregl_la_LIBADD = $(EGL_LIBS) $(GLX_SYS_LIBS) libglamor.la
 libglamoregl_la_SOURCES = glamor_eglmodule.c $(top_srcdir)/src/glamor_egl.c
 libglamoregl_la_CFLAGS = $(AM_CFLAGS) $(GLX_DEFINES) -I$(top_srcdir)/src $(LIBDRM_CFLAGS) $(EGL_CFLAGS)
 endif
diff --git a/src/glamor_compositerects.c b/src/glamor_compositerects.c
index 5fe1bbf..f1564a2 100644
--- a/src/glamor_compositerects.c
+++ b/src/glamor_compositerects.c
@@ -131,16 +131,6 @@ glamor_composite_rectangles(CARD8	 op,
 		return;
 	}
 
-	pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
-	priv = glamor_get_pixmap_private(pixmap);
-
-	if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
-		goto fallback;
-	if (dst->alphaMap) {
-		DEBUGF("%s: fallback, dst has an alpha-map\n", __FUNCTION__);
-		goto fallback;
-	}
-
 	if ((color->red|color->green|color->blue|color->alpha) <= 0x00ff) {
 		switch (op) {
 		case PictOpOver:
@@ -204,6 +194,16 @@ glamor_composite_rectangles(CARD8	 op,
 		return;
 	}
 
+	pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
+	priv = glamor_get_pixmap_private(pixmap);
+
+	if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
+		goto fallback;
+	if (dst->alphaMap) {
+		DEBUGF("%s: fallback, dst has an alpha-map\n", __FUNCTION__);
+		goto fallback;
+	}
+
 	need_free_region = TRUE;
 
 	DEBUGF("%s: drawable extents (%d, %d),(%d, %d) x %d\n",
diff --git a/src/glamor_copyarea.c b/src/glamor_copyarea.c
index 7d06833..4e6f953 100644
--- a/src/glamor_copyarea.c
+++ b/src/glamor_copyarea.c
@@ -318,7 +318,8 @@ __glamor_copy_n_to_n(DrawablePtr src,
 		dx, dy,
 		src_pixmap, dst_pixmap);
 #ifndef GLAMOR_GLES2
-	if ((overlaped || glamor_priv->state != RENDER_STATE
+	if (!overlaped &&
+	    (glamor_priv->state != RENDER_STATE
 	     || !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex)
 	    && glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx,
 					   dy)) {
diff --git a/src/glamor_egl.c b/src/glamor_egl.c
index a248aa2..cd0bdc0 100644
--- a/src/glamor_egl.c
+++ b/src/glamor_egl.c
@@ -116,7 +116,7 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn)
 _X_EXPORT void
 glamor_egl_make_current(ScreenPtr screen)
 {
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	struct glamor_egl_screen_private *glamor_egl =
 	    glamor_egl_get_screen_private(scrn);
 
@@ -139,7 +139,7 @@ glamor_egl_make_current(ScreenPtr screen)
 _X_EXPORT void
 glamor_egl_restore_context(ScreenPtr screen)
 {
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	struct glamor_egl_screen_private *glamor_egl =
 	    glamor_egl_get_screen_private(scrn);
 
@@ -221,7 +221,7 @@ glamor_create_texture_from_image(struct glamor_egl_screen_private
 Bool
 glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
 {
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	struct glamor_egl_screen_private *glamor_egl;
 	PixmapPtr	screen_pixmap;
 
@@ -245,7 +245,7 @@ glamor_egl_create_textured_screen_ext(ScreenPtr screen,
 				      int stride,
 				      PixmapPtr *back_pixmap)
 {
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	struct glamor_egl_screen_private *glamor_egl;
 
 	glamor_egl = glamor_egl_get_screen_private(scrn);
@@ -272,7 +272,7 @@ Bool
 glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
 {
 	ScreenPtr screen = pixmap->drawable.pScreen;
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	struct glamor_egl_screen_private *glamor_egl;
 	EGLImageKHR image;
 	GLuint texture;
@@ -318,7 +318,7 @@ done:
 static void
 _glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
 {
-	ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
 	EGLImageKHR image;
 	struct glamor_egl_screen_private *glamor_egl =
 	    glamor_egl_get_screen_private(scrn);
@@ -338,7 +338,7 @@ _glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
 _X_EXPORT void
 glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
 {
-	ScrnInfoPtr scrn = xf86Screens[front->drawable.pScreen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(front->drawable.pScreen);
 	struct glamor_egl_screen_private *glamor_egl =
 	    glamor_egl_get_screen_private(scrn);
 	EGLImageKHR old_front_image;
@@ -371,7 +371,7 @@ glamor_egl_close_screen(CLOSE_SCREEN_ARGS_DECL)
 	PixmapPtr screen_pixmap;
 	EGLImageKHR back_image;
 
-	scrn = xf86Screens[screen->myNum];
+	scrn = xf86ScreenToScrn(screen);
 	glamor_egl = glamor_egl_get_screen_private(scrn);
 	screen_pixmap = screen->GetScreenPixmap(screen);
 
@@ -417,7 +417,7 @@ glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl,
 void
 glamor_egl_screen_init(ScreenPtr screen)
 {
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	struct glamor_egl_screen_private *glamor_egl =
 	    glamor_egl_get_screen_private(scrn);
 
@@ -588,7 +588,7 @@ glamor_gl_dispatch_init(ScreenPtr screen,
 			struct glamor_gl_dispatch *dispatch,
 			int gl_version)
 {
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	struct glamor_egl_screen_private *glamor_egl =
 	    glamor_egl_get_screen_private(scrn);
 	if (!glamor_gl_dispatch_init_impl
diff --git a/src/glamor_utils.h b/src/glamor_utils.h
index 36beb49..d307838 100644
--- a/src/glamor_utils.h
+++ b/src/glamor_utils.h
@@ -80,8 +80,7 @@
 
 #define pixmap_priv_get_fbo_off(_priv_, _xoff_, _yoff_)		\
    do {								\
-	if (unlikely(_priv_ && (_priv_)->type				\
-		== GLAMOR_TEXTURE_LARGE)) {			\
+	if (unlikely(_priv_ && (_priv_)->type == GLAMOR_TEXTURE_LARGE)) {  \
 		*(_xoff_) = - (_priv_)->large.box.x1;	\
 		*(_yoff_) = - (_priv_)->large.box.y1;	\
 	} else {						\
