Refactor models related to submissions

Group attribute constraints and update many of the queries.