Revert "Clean up relationship selection code.". Wasn't meant to be pushed.

This reverts commit ea72900c96b3e48440284cbc6ab0f7d701755ad0.