Minor code reorganization