Refactored models to include relations and aggregations