Code from the old results.py.