Commented and refactored Layout class. Added exceptions.