Initial ranking script; lots to clean up