Fix a couple of bugs in rd_average.py.