Refactoring, incomplete.