Fixed some bugs with adding relationships.