Revert "Rearranged code slightly to make more sense."

This reverts commit 9b8446b14e0602774c45f9992dc886b0bb572367.