Adding junction table, queries and more refractoring