Minor code reorganizing