Some cleanup and rearrangement.