Minor code shuffle to make the flow a little more obvious.