some refactoring, some work on categories and repository