Fix many-to-many relationships to use secondary tables