Fix a crash when expansion was -1.
Fix warning due to global var.