Fix issue #794. Better errormessage on duplicate mref.
Merge pull request #1288 from erwinwinder/master

Fix issue #794. Better errormessage on duplicate mref.