added constraints, fixed relationships