Refactoring the core a bit