Fixed early caching problem
Groups also check domain and some refactoring