change `idmap` to hold vectors of elements.(fixes #1822)

see #1822
should I write a test?