Optimize delete

Optimize deletion of stale records from the DB. When updating a large DB, rather than deleting old records as we go, delete in one big batch at the end for efficiency's sake.