Rearrange to make code more logical.