slight refactor to relationship definitions; fixed iterating over embedded hasMany