1040 fix relations in models

should fix #1040