This is a first step toward general depth sorting.
This properly reflects the modularity of the code, and it simplifies indentation and syntax highlighting.