Add IdentityDict class for reference tracking