diff --git a/record-and-playback/slides/playback/slides/lib/writing.js b/record-and-playback/slides/playback/slides/lib/writing.js
index 9598a729996714f4fb41f26e23090f20e7c1ce95..b3f2f19a808dbe6ddea9b5780029f067e8d359ed 100644
--- a/record-and-playback/slides/playback/slides/lib/writing.js
+++ b/record-and-playback/slides/playback/slides/lib/writing.js
@@ -244,7 +244,10 @@ p.code({
 					//as long as it is a main shape, it can be drawn... no intermediate steps.
 					else if(main_shapes_times.indexOf(time_s) !== -1) {
 						//As long as the undo event hasn't happened yet...
-						if(parseFloat(shape.getAttribute("undo")) > t) {
+						if(parseFloat(shape.getAttribute("undo")) === -1) {
+							shape.style.visibility = "visible";
+						}
+						else if (parseFloat(shape.getAttribute("undo")) > t) {
 							shape.style.visibility = "visible";
 						}
 						else {
@@ -254,6 +257,7 @@ p.code({
 				}
 				//for the shape with the time specific to the current time
 				else if(time_f === t) {
+					console.log("showing" + shape.id);
 					shape.style.visibility = "visible";
 				}
 				//for shapes that shouldn't be drawn yet (larger time than current time), don't draw them.
diff --git a/record-and-playback/slides/scripts/publish/slides.rb b/record-and-playback/slides/scripts/publish/slides.rb
index 6660a7b6645ce40c10880aa8eeadf548a1bb2a8d..299761c6e5b49755647749a8b6b332dd2d1908d2 100755
--- a/record-and-playback/slides/scripts/publish/slides.rb
+++ b/record-and-playback/slides/scripts/publish/slides.rb
@@ -176,20 +176,45 @@ if (playback == "slides")
 							# It cannot be an undo for another shape already.
 							if !(undos.has_key? shape['timestamp'])
 								# Must be part of this presentation of course
-								if shape['presentation'] == undo['presentation']
+								if shape.xpath(".//pageNumber")[0].text() == undo.xpath(".//pageNumber")[0].text()
 									# Must be a shape in this page too.
-									if shape['pageNumber'] == undo['pageNumber']
-										closest_shape = shape
+									if shape.xpath(".//presentation")[0].text() == undo.xpath(".//presentation")[0].text()
+										if ((shape.xpath(".//type")[0].text() == "rectangle") || (shape.xpath(".//type")[0].text() == "ellipse"))
+											shape_already_processed = false
+											undos.each do |u, v|
+												if shape.xpath(".//dataPoints")[0].text().split(",")[0] == u.xpath(".//dataPoints")[0].text().split(",")[0]
+													if shape.xpath(".//dataPoints")[0].text().split(",")[1] == u.xpath(".//dataPoints")[0].text().split(",")[1]
+														shape_already_processed = true
+													end
+												end
+											end
+											if(undos.length == 0) 
+												shape_already_processed
+											end 
+											if !(shape_already_processed)
+												closest_shape = shape
+											end
+										else
+											closest_shape = shape
+										end
 									end
 								end
 							end
 						end
 					end
 				end
-				#BigBlueButton.logger.info("Now puting in undos")
-				undos[closest_shape['timestamp']] = undo['timestamp']
-				#BigBlueButton.logger.info("put in undos")
+				if(closest_shape != nil)
+					undos[closest_shape] = undo['timestamp']
+				end
 			end
+			
+			undos_temp = {}
+			undos.each do |un, val|
+				undos_temp[un['timestamp']] = val
+			end
+			undos = undos_temp
+			
+			
 			#BigBlueButton.logger.info("Made it through the looping")
 			BigBlueButton.logger.info("Undos: #{undos}")