Refactoring of the core logic.