Repository and CMS refactoring - wip