Optimized CubeGenerator.