Added code to delete unused external entities upon rollback