Smaller code cleanup... mostly just moving things around, and fixing their visibility.