clean up code.
do not accept new records that have older timestamps than ones in database
when adding the records.
fix the bug that clear an error # by zero.