Cubes refactoring