Some restructuring and cleanup.