Fixed add_data() so that records could be merged, replaced or left alone.