Updated logic to handle quizes of various lengths. Bug fixes.