diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp
index d2b7047667dc4cc4cf689976ccbfa97bca6df9e9..86d533bb94ec63de921fcfbf74fbcccef72d5e9b 100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@ -321,7 +321,7 @@ void BVHEmbree::mem_monitor(ssize_t bytes)
 
 void BVHEmbree::build(Progress& progress, Stats *stats_)
 {
-	stats = stats_;
+    stats = stats_;
 
     progress.set_substatus("Building BVH");
 
@@ -365,12 +365,12 @@ void BVHEmbree::build(Progress& progress, Stats *stats_)
 	    add_object(ob, i);
 	}
 	++i;
-	if(progress.get_cancel()) return;
-    }
-
-    if(progress.get_cancel()) {
-	delete_rtcScene();
-	return;
+        
+        if(progress.get_cancel()) {
+            delete_rtcScene();
+            stats = NULL;
+            return;
+        }
     }
 
     rtcSetSceneProgressMonitorFunction(scene, rtc_progress_func, &progress);
@@ -380,14 +380,14 @@ void BVHEmbree::build(Progress& progress, Stats *stats_)
 
     if(progress.get_cancel()) {
 	delete_rtcScene();
-		stats = NULL;
+	stats = NULL;
 	return;
     }
 
     progress.set_substatus("Packing geometry");
     pack_nodes(NULL);
 
-	stats = NULL;
+    stats = NULL;
 }
 
 void BVHEmbree::add_object(Object *ob, int i)
@@ -414,7 +414,7 @@ void BVHEmbree::add_instance(Object *ob, int i)
     }
 
 	const size_t num_motion_steps = ob->use_motion() ? ob->motion.size() : 1;
-    RTCGeometry geom_id = rtcNewGeometry(rtc_shared_device, RTC_GEOMETRY_TYPE_INSTANCE); // EMBREE_FIXME: check if geometry gets properly committed
+    RTCGeometry geom_id = rtcNewGeometry(rtc_shared_device, RTC_GEOMETRY_TYPE_INSTANCE);
     rtcSetGeometryInstancedScene(geom_id, instance_bvh->scene);
     rtcSetGeometryTimeStepCount(geom_id, num_motion_steps);
 
@@ -457,7 +457,7 @@ void BVHEmbree::add_triangles(Object *ob, int i)
 
     const size_t num_triangles = mesh->num_triangles();
 
-    RTCGeometry geom_id = rtcNewGeometry(rtc_shared_device, RTC_GEOMETRY_TYPE_TRIANGLE); // EMBREE_FIXME: check if geometry gets properly committed
+    RTCGeometry geom_id = rtcNewGeometry(rtc_shared_device, RTC_GEOMETRY_TYPE_TRIANGLE);
     rtcSetGeometryBuildQuality(geom_id, params.bvh_type == SceneParams::BVH_DYNAMIC ? RTC_BUILD_QUALITY_REFIT : RTC_BUILD_QUALITY_MEDIUM);
     rtcSetGeometryTimeStepCount(geom_id, num_motion_steps);
 
@@ -509,7 +509,6 @@ void BVHEmbree::update_tri_vertex_buffer(RTCGeometry geom_id, const Mesh* mesh)
     }
     const size_t num_verts = mesh->verts.size();
 
-
     for (int t = 0; t < num_motion_steps; t++) {
 	const float3 *verts;
 	if(t == t_mid) {
@@ -547,12 +546,23 @@ void BVHEmbree::update_curve_vertex_buffer(RTCGeometry geom_id, const Mesh* mesh
 	}
     }
 
-    const size_t num_keys = mesh->curve_keys.size();
+    const size_t num_curves = mesh->num_curves();
+    //const size_t num_keys = mesh->curve_keys.size();
+    size_t num_keys = 0;
+    for (size_t j = 0; j < num_curves; j++) {
+	Mesh::Curve c = mesh->get_curve(j);
+	if(c.num_segments() > 0) {
+	    num_keys += use_curves ? (c.num_segments() * 3 + 1) : c.num_keys;
+	} 
+        else {
+	    assert(0);
+	}
+    }
 
     /* Copy the CV data to Embree */
     int t_mid = (num_motion_steps - 1) / 2;
     const float *curve_radius = &mesh->curve_radius[0];
-    for (int t = 0; t < num_motion_steps; t++) {	//RTCBufferType buffer_type = RTC_BUFFER(RTC_BUFFER_TYPE_VERTEX, t);
+    for (int t = 0; t < num_motion_steps; t++) {
 	const float3 *verts;
 	if(t == t_mid || attr_mP == NULL) {
 	    verts = &mesh->curve_keys[0];
@@ -624,13 +634,13 @@ void BVHEmbree::add_curves(Object* ob, int i)
     }
 
     const size_t num_curves = mesh->num_curves();
-    size_t num_keys = 0;
+    //size_t num_keys = 0;
     size_t num_segments = 0;
     for (size_t j = 0; j < num_curves; j++) {
 	Mesh::Curve c = mesh->get_curve(j);
 	if(c.num_segments() > 0) {
 	    num_segments += c.num_segments();
-	    num_keys += use_curves ? (c.num_segments() * 3 + 1) : c.num_keys;
+	    //num_keys += use_curves ? (c.num_segments() * 3 + 1) : c.num_keys;
 	} 
         else {
 	    assert(0);
@@ -678,7 +688,7 @@ void BVHEmbree::add_curves(Object* ob, int i)
 
     } 
     else {
-	geom_id = rtcNewGeometry(rtc_shared_device, RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE); // EMBREE_FIXME: check if geometry gets properly committed
+	geom_id = rtcNewGeometry(rtc_shared_device, RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE);
 
 	/* Split the Cycles curves into Embree line segments, each with 2 CVs */
 	unsigned *rtc_indices = (unsigned*) rtcSetNewGeometryBuffer(geom_id, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, sizeof (int), num_segments);
@@ -697,12 +707,12 @@ void BVHEmbree::add_curves(Object* ob, int i)
 	    }
 	}
     }
-
-    update_curve_vertex_buffer(geom_id, mesh);
     
     rtcSetGeometryBuildQuality(geom_id, params.bvh_type == SceneParams::BVH_DYNAMIC ? RTC_BUILD_QUALITY_REFIT : RTC_BUILD_QUALITY_MEDIUM);
     rtcSetGeometryTimeStepCount(geom_id, num_motion_steps);
 
+    update_curve_vertex_buffer(geom_id, mesh);
+    
     rtcSetGeometryUserData(geom_id, (void*) prim_offset);
     rtcSetGeometryOccludedFilterFunction(geom_id, rtc_filter_func);
     rtcSetGeometryMask(geom_id, ob->visibility);