Fixed bug in handling n-ary relationship