Fix crashes in battles
Fix race conditions with challenges

For example, these race conditions could be used to bypass legality
checking in unrated battles.