Refactors alias deletion code