Finish refactoring core