Issue 4417 copy host mixes up relationship

Fixed the issue and committed the code for review, please check it.