Added better handling of removed instances.