Removed temp variables from generate relationship functions