TODO Optimize set_record, feeding it the original state for the record, maybe nil indicating it didn't exist, and somethin else to say "i don't know".