Fix bug that caused relationship not being set