Changed the saving of records at end of intervals