Make Env and Dir into templates too.

And add environment variable expansion