finally cleans up the cube class. Adds further explanatory comments.