Merging some of Desmond's changes from "rankit.zip"