I keep a dictionary of {bot.Name:unsavedBattles} and once there are more than 30 entries it gets written.