Fix #2035: slightly nasty hack to work around toObject messiness