Made the cube class faster and simpler.