Further restructuring and refactoring.