Clean up page ordering code.