Initial refactoring