Optimize purging.

Now only purge if there is something to purge.
Also, set savedFirstTime and archived time range appropriately.
(Which is needed for the optimization.)

Change-Id: Idcd33319a84def3ce0318d886f10c6800369e7f9
Remove archiveMtx.

Change-Id: Ie8019f860bbda68621f74380c90a4e57930d3d7a