Refactor domains and events repo