initial refactoring complete