Fixes odd bug where relationships were being generated incorrectly.