Minor code restructuring