Core refactoring - better file structure