Refactor models related to submissions

Group attribute constraints and update many of the queries.

And some other minor refactoring to prevent future Hounding.