Refactoring core. Round 1.