Initial refactoring finished.