Moderate refactoring