Minor code shuffling to simplify setup.