Fixed bug with object references and deleting