Almost done refactoring