Integrating Andrew's refactoring