Improve handling of variables in external tool arguments.

Code cleanup.