Moderate refactor