Refactoring to start removing external dependencies for mortar core