Fixes #4032 - Use object.id for comparisons

I'm sure there's more of these, but this is a start.