Clean up ranking code a bit.