Fix #504

Determine whether to copy objects by their constructor names, since the
prototypes do not necessarily match