Refactoring almost done