diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index e5e734e4e573d1ea77f289d8f7c29ea895ec25a2..bf1e327c52e39cd446313283d98a9bdff0acc043 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -700,7 +700,9 @@ GHOST_TSuccess GHOST_WindowWin32::initMultisample(PIXELFORMATDESCRIPTOR pfd)
 		WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
 		WGL_COLOR_BITS_ARB, pfd.cColorBits,
 		WGL_DEPTH_BITS_ARB, pfd.cDepthBits,
+#ifdef GHOST_OPENGL_ALPHA
 		WGL_ALPHA_BITS_ARB, pfd.cAlphaBits,
+#endif
 		WGL_STENCIL_BITS_ARB, pfd.cStencilBits,
 		WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
 		WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
@@ -1310,8 +1312,10 @@ static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd)
 
 	weight += pfd.cColorBits - 8;
 
+#ifdef GHOST_OPENGL_ALPHA
 	if (pfd.cAlphaBits > 0)
 		weight ++;
+#endif
 
 	/* want swap copy capability -- it matters a lot */
 	if (pfd.dwFlags & PFD_SWAP_COPY) weight += 16;
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 20855a126a8cae04cac61c5c72c16d767d83de15..25d7c181b68b0e0152914cbc4a27f061030c6e72 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -211,7 +211,9 @@ GHOST_WindowX11(
 		attributes[i++] = GLX_BLUE_SIZE;  attributes[i++] = 1;
 		attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1;
 		attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1;
+#ifdef GHOST_OPENGL_ALPHA
 		attributes[i++] = GLX_ALPHA_SIZE; attributes[i++] = 1;
+#endif
 		/* GLX >= 1.4 required for multi-sample */
 		if (samples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) {
 			attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1;
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index bd4c234781534c76293bdce34d1ba20a5c42522a..8299446bfdaab514cc1fffcf7eb8e2f2ad4b8619 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -251,7 +251,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
 /* Note: 'Preview Range' tools are defined in anim_ops.c */
 
 /* Draw preview range 'curtains' for highlighting where the animation data is */
-void ANIM_draw_previewrange(const bContext *C, View2D *v2d)
+void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 {
 	Scene *scene = CTX_data_scene(C);
 	
@@ -262,9 +262,9 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d)
 		glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
 		
 		/* only draw two separate 'curtains' if there's no overlap between them */
-		if (PSFRA < PEFRA) {
+		if (PSFRA < PEFRA + end_frame_width) {
 			glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
-			glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+			glRectf((float)(PEFRA + end_frame_width), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
 		}
 		else {
 			glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index f698f9b0b11711253247ec076447fc3022761e00..1de1731b5152b81cade85f66933aff0de93c33cc 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -491,7 +491,7 @@ void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag);
 /* ------------- Preview Range Drawing -------------- */
 
 /* main call to draw preview range curtains */
-void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d);
+void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d, int end_frame_width);
 
 /* ************************************************* */
 /* F-MODIFIER TOOLS */
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 107ff9668f0125ee0ec1b55df96b3dcc2827e3c9..79b8cd5e695ddfafad96633c2d39f1e23bdc8b19 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -809,7 +809,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
 
 	/* TODO: as sculpt and other paint modes are unified, this
 	 * special mode of drawing will go away */
-	if (vc.obact && vc.obact->sculpt) {
+	if ((mode == PAINT_SCULPT) && vc.obact->sculpt) {
 		float location[3];
 		int pixel_radius, hit;
 
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index ea5175df39ab0be6fdedad884144e95f1e3b945a..9d727dc689f5fa8a5040b6b25e544ffe1fab5db7 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -90,7 +90,9 @@ typedef struct PaintStroke {
 	int stroke_started;
 	/* event that started stroke, for modal() return */
 	int event_type;
-	
+	/* check if stroke variables have been initialized */
+	bool stroke_init;
+	/* check if various brush mapping variables have been initialized */
 	bool brush_init;
 	float initial_mouse[2];
 	/* cached_pressure stores initial pressure for size pressure influence mainly */
@@ -389,17 +391,17 @@ static float paint_space_stroke_spacing_variable(const Scene *scene, PaintStroke
 		 * are aligned nicely with no overlap. for this the spacing needs to be
 		 * the average of the previous and next size. */
 		float s = paint_space_stroke_spacing(scene, stroke, 1.0f, pressure);
-		float q = s*dpressure/(2.0f*length);
-		float pressure_fac = (1.0f + q)/(1.0f - q);
+		float q = s * dpressure / (2.0f * length);
+		float pressure_fac = (1.0f + q) / (1.0f - q);
 
 		float last_size_pressure = stroke->last_pressure;
-		float new_size_pressure = stroke->last_pressure*pressure_fac;
+		float new_size_pressure = stroke->last_pressure * pressure_fac;
 
 		/* average spacing */
 		float last_spacing = paint_space_stroke_spacing(scene, stroke, last_size_pressure, pressure);
 		float new_spacing = paint_space_stroke_spacing(scene, stroke, new_size_pressure, pressure);
 
-		return 0.5f*(last_spacing + new_spacing);
+		return 0.5f * (last_spacing + new_spacing);
 	}
 	else {
 		/* no size pressure */
@@ -432,9 +434,9 @@ static int paint_space_stroke(bContext *C, wmOperator *op, const float final_mou
 			float spacing = paint_space_stroke_spacing_variable(scene, stroke, pressure, dpressure, length);
 			
 			if (length >= spacing) {
-				mouse[0] = stroke->last_mouse_position[0] + dmouse[0]*spacing;
-				mouse[1] = stroke->last_mouse_position[1] + dmouse[1]*spacing;
-				pressure = stroke->last_pressure + (spacing/length)*dpressure;
+				mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing;
+				mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing;
+				pressure = stroke->last_pressure + (spacing / length) * dpressure;
 
 				paint_brush_stroke_add_step(C, op, mouse, pressure);
 
@@ -654,7 +656,8 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
 	PaintStroke *stroke = op->customdata;
 	PaintSample sample_average;
 	float mouse[2];
-	int first = 0;
+	bool first_dab = false;
+	bool first_modal = false;
 	float zoomx, zoomy;
 	bool redraw = false;
 	float pressure;
@@ -675,23 +678,28 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
 	if (event->type == NDOF_MOTION)
 		return OPERATOR_PASS_THROUGH;
 
+	/* one time initialization */
+	if(!stroke->stroke_init) {
+		stroke->smooth_stroke_cursor =
+			    WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke);
+
+		stroke->stroke_init = true;
+		first_modal = true;
+	}
+
+	/* one time stroke initialization */
 	if (!stroke->stroke_started) {
-		copy_v2_v2(stroke->last_mouse_position, sample_average.mouse);
 		stroke->last_pressure = sample_average.pressure;
+		copy_v2_v2(stroke->last_mouse_position, sample_average.mouse);
 		stroke->stroke_started = stroke->test_start(C, op, sample_average.mouse);
 		BLI_assert((stroke->stroke_started & ~1) == 0);  /* 0/1 */
-		stroke->last_pressure = pressure;
 
 		if (stroke->stroke_started) {
-			stroke->smooth_stroke_cursor =
-			    WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke);
-
 			if (stroke->brush->flag & BRUSH_AIRBRUSH)
 				stroke->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate);
-		}
 
-		first = 1;
-		//ED_region_tag_redraw(ar);
+			first_dab = true;
+		}
 	}
 
 	/* Cancel */
@@ -702,16 +710,15 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
 			return paint_stroke_cancel(C, op);
 	}
 
-	if (event->type == stroke->event_type && event->val == KM_RELEASE) {
+	if (event->type == stroke->event_type && event->val == KM_RELEASE && !first_modal) {
 		stroke_done(C, op);
 		return OPERATOR_FINISHED;
 	}
-	else if ((first) ||
-	         (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) ||
+	else if (first_modal || (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) ||
 	         (event->type == TIMER && (event->customdata == stroke->timer)) )
 	{
-		if (stroke->stroke_started) {
-			if (paint_smooth_stroke(stroke, mouse, &pressure, &sample_average, mode)) {
+		if (paint_smooth_stroke(stroke, mouse, &pressure, &sample_average, mode)) {
+			if (stroke->stroke_started) {
 				if (paint_space_stroke_enabled(stroke->brush, mode)) {
 					if (paint_space_stroke(C, op, mouse, pressure))
 						redraw = true;
@@ -726,8 +733,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 	/* we want the stroke to have the first daub at the start location
 	 * instead of waiting till we have moved the space distance */
-	if (first &&
-	    stroke->stroke_started &&
+	if (first_dab &&
 	    paint_space_stroke_enabled(stroke->brush, mode) &&
 	    !(stroke->brush->flag & BRUSH_ANCHORED) &&
 	    !(stroke->brush->flag & BRUSH_SMOOTH_STROKE))
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 137ac367815e222fe2679e030b5c31c6e59114d2..4aa19dca9fed6ae593e89b5fff471c3d5246508e 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -205,7 +205,7 @@ static void action_main_area_draw(const bContext *C, ARegion *ar)
 	
 	/* preview range */
 	UI_view2d_view_ortho(v2d);
-	ANIM_draw_previewrange(C, v2d);
+	ANIM_draw_previewrange(C, v2d, 0);
 
 	/* callback */
 	UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 98c26a447b7f348a484025e8d3f002206727bec9..1ec31368217d613894a9e2bd14b9a9fe6f546541 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -295,7 +295,7 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
 	
 	/* preview range */
 	UI_view2d_view_ortho(v2d);
-	ANIM_draw_previewrange(C, v2d);
+	ANIM_draw_previewrange(C, v2d, 0);
 	
 	/* callback */
 	UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index d0773bfe8189a702b7219f78904c2894f5097c6a..5c01a982e2600a4aaf60e937a4299eb9c890e2f0 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -311,7 +311,7 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar)
 	
 	/* preview range */
 	UI_view2d_view_ortho(v2d);
-	ANIM_draw_previewrange(C, v2d);
+	ANIM_draw_previewrange(C, v2d, 0);
 	
 	/* callback */
 	UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index bb4910413f6da64b02581a8defe2c80e8873b5f6..2d3b5165ea3428cc0205081495f9ea5a0f255fa2 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1381,7 +1381,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
 	 * frame range used is preview range or scene range */
 	UI_ThemeColorShadeAlpha(TH_BACK, -25, -100);
 
-	if (PSFRA < PEFRA+1) {
+	if (PSFRA < PEFRA + 1) {
 		glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
 		glRectf((float)(PEFRA+1), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
 	}
@@ -1457,7 +1457,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
 	
 	/* preview range */
 	UI_view2d_view_ortho(v2d);
-	ANIM_draw_previewrange(C, v2d);
+	ANIM_draw_previewrange(C, v2d, 1);
 
 	/* overlap playhead */
 	if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
diff --git a/source/blender/freestyle/intern/system/RenderMonitor.h b/source/blender/freestyle/intern/system/RenderMonitor.h
index 614513b3c56b940861dbdbd91b308ec435601bb6..3bb872cbdfb9f54181c1e4b321838a2335030958 100644
--- a/source/blender/freestyle/intern/system/RenderMonitor.h
+++ b/source/blender/freestyle/intern/system/RenderMonitor.h
@@ -44,6 +44,21 @@ public:
 
 	virtual ~RenderMonitor() {}
 
+	inline void setInfo(string info)
+	{
+		if (_re && !info.empty()) {
+			_re->i.infostr = info.c_str();
+			_re->stats_draw(_re->sdh, &_re->i);
+			_re->i.infostr = NULL;
+		}
+	}
+
+	inline void progress(float i)
+	{
+		if (_re)
+			_re->progress(_re->prh, i);
+	}
+
 	inline bool testBreak()
 	{
 		return _re && _re->test_break(_re->tbh);
diff --git a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
index 2d8d3b30f84f7e5edcb1f8944080f2ef4f4473c2..61ad78a85673534c61bbf5aa44b0fb51f3444e8a 100644
--- a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
+++ b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
@@ -83,6 +83,13 @@ void AverageAreaGridDensityProvider::initialize(const real proscenium[4], real s
 	}
 
 	_cellSize = sqrt(cellArea);
+	unsigned maxCells = 931; // * 1.1 = 1024
+	if (std::max(prosceniumWidth, prosceniumHeight) / _cellSize > maxCells) {
+		if (G.debug & G_DEBUG_FREESTYLE) {
+			cout << "Scene-dependent cell size (" << _cellSize << " square) is too small." << endl;
+		}
+		_cellSize = std::max(prosceniumWidth, prosceniumHeight) / maxCells;
+	}
 	// Now we know how many cells make each side of our grid
 	_cellsX = ceil(prosceniumWidth / _cellSize);
 	_cellsY = ceil(prosceniumHeight / _cellSize);
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index bbbf997b46368ec735dba08dbf57f9f311c7953d..20b0f6576bb65fd8eb372a9fb31273de712cf59f 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -28,6 +28,7 @@
 #include <algorithm>
 #include <memory>
 #include <stdexcept>
+#include <sstream>
 
 #include "FRS_freestyle.h"
 
@@ -412,13 +413,24 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
 	int nSamples = 0;
 	vector<WFace*> wFaces;
 	WFace *wFace = NULL;
+	unsigned cnt = 0;
+	unsigned cntStep = (unsigned)ceil(0.01f * vedges.size());
 	unsigned tmpQI = 0;
 	unsigned qiClasses[256];
 	unsigned maxIndex, maxCard;
 	unsigned qiMajority;
 	for (vector<ViewEdge*>::iterator ve = vedges.begin(), veend = vedges.end(); ve != veend; ve++) {
-		if (iRenderMonitor && iRenderMonitor->testBreak())
-			break;
+		if (iRenderMonitor) {
+			if (iRenderMonitor->testBreak())
+				break;
+			if (cnt % cntStep == 0) {
+				stringstream ss;
+				ss << "Freestyle: Visibility computations " << (100 * cnt / vedges.size()) << "%";
+				iRenderMonitor->setInfo(ss.str());
+				iRenderMonitor->progress((float)cnt / vedges.size());
+			}
+			cnt++;
+		}
 #if LOGGING
 		if (_global.debug & G_DEBUG_FREESTYLE) {
 			cout << "Processing ViewEdge " << (*ve)->getId() << endl;
@@ -583,6 +595,12 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
 
 		wFaces.clear();
 	}
+	if (iRenderMonitor) {
+		stringstream ss;
+		ss << "Freestyle: Visibility computations " << (100 * cnt / vedges.size()) << "%";
+		iRenderMonitor->setInfo(ss.str());
+		iRenderMonitor->progress((float)cnt / vedges.size());
+	}
 }
 
 template <typename G, typename I>
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index af537db0203ab2f61d4bee0db3a77bd35453eef6..90383021c908956f59f6c0cf6ec96e68a5fbf659 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -543,6 +543,8 @@ PyAttributeDef BL_ActionActuator::Attributes[] = {
 	KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
 	KX_PYATTRIBUTE_RO_FUNCTION("channelNames", BL_ActionActuator, pyattr_get_channel_names),
 	KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
+	KX_PYATTRIBUTE_SHORT_RW("layer", 0, 7, true, BL_ActionActuator, m_layer),
+	KX_PYATTRIBUTE_FLOAT_RW("layerWeight", 0, 1.0, BL_ActionActuator, m_layer_weight),
 	KX_PYATTRIBUTE_RW_FUNCTION("frame", BL_ActionActuator, pyattr_get_frame, pyattr_set_frame),
 	KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_propname),
 	KX_PYATTRIBUTE_STRING_RW("framePropName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_framepropname),