First commit is the same as the one in !70 (closed). Second one introduces the periodic cleanup logic