handle relation selections, cleanup code,
closes #2469, #2470