Updated clean_up() and pulled out record_compare() so updating/deleting was clearer.