WIP: refactoring core.