Major app refactor. Incorporate moodlequery.