Reorder some code for clarity.