Full refactoring based on new integration