Fixed bugs with RIDs and record insert/update