Fixing infinite loop in alias replacement.