Minor rearrangements of code