Did some input validation and fixed a bug for classes with only one section.