Move more functionality into contestgen.py.