         )
 
     drawRanges: (datasetElement, dataset, records) ->
-        datasetElement.selectAll('rect').remove()
-
-        r = datasetElement.selectAll('rect')
+        rect = (elem) =>
+            elem.attr('class', 'record')
+                .attr('x', (record) => @scales.x(new Date(record[0])) )
+                .attr('y', - (@options.ticksize + 3) * dataset.index + -(@options.ticksize-2) )
+                .attr('width', (record) => @scales.x(new Date(record[1])) - @scales.x(new Date(record[0])) )
+                .attr('height', (@options.ticksize-2))
+                .attr('stroke', d3.rgb(dataset.color).darker())
+                .attr('stroke-width', 1)
+
+        r = datasetElement.selectAll('rect.record')
             .data(records)
+            .call(rect)
 
         r.enter().append('rect')
-            .attr('x', (record) => @scales.x(new Date(record[0])) )
-            .attr('y', - (@options.ticksize + 3) * dataset.index + -(@options.ticksize-2) )
-            .attr('width', (record) => @scales.x(new Date(record[1])) - @scales.x(new Date(record[0])) )
-            .attr('height', (@options.ticksize-2))
-            .attr('stroke', d3.rgb(dataset.color).darker())
-            .attr('stroke-width', 1)
+            .call(rect)
             .call((recordElement) => @setupRecord(recordElement, dataset))
 
         r.exit().remove()
 
     drawPoints: (datasetElement, dataset, records) ->
-        datasetElement.selectAll('circle').remove()
-        p = datasetElement.selectAll('circle')
+        circle = (elem) =>
+            elem.attr('class', 'record')
+                .attr('cx', (a) =>
+                    if Array.isArray(a)
+                        return @scales.x(new Date(a[0]))
+                    else
+                        return @scales.x(new Date(a))
+                )
+                .attr('cy', - (@options.ticksize + 3) * dataset.index - (@options.ticksize - 2) / 2)
+                .attr('stroke', d3.rgb(dataset.color).darker())
+                .attr('stroke-width', 1)
+                .attr('r', @options.ticksize / 2)
+
+        p = datasetElement.selectAll('circle.record')
             .data(records)
+            .call(circle)
 
         p.enter().append('circle')
-            .attr('cx', (a) =>
-                if Array.isArray(a)
-                    return @scales.x(new Date(a[0]))
-                else
-                    return @scales.x(new Date(a))
-            )
-            .attr('cy', - (@options.ticksize + 3) * dataset.index - (@options.ticksize - 2) / 2)
-            .attr('stroke', d3.rgb(dataset.color).darker())
-            .attr('stroke-width', 1)
-            .attr('r', @options.ticksize / 2)
+            .call(circle)
             .call((recordElement) => @setupRecord(recordElement, dataset))
 
         p.exit().remove()

            debounceTime: @options.debounce,
            ordinal: @ordinal,
            element: element,
            histogram: definition.histogram
        })

        @reloadDataset(id)

# Dataset utility class for internal use only
class Dataset
    constructor: (options) ->
        { @id,  @color, @source, @sourceParams, @index, @records, @paths, @lineplot, @ordinal, @element, @histogramThreshold } = options
        @syncDebounced = debounce(@sync, options.debounceTime)

    getSource: ->
