Improve ssh detection.

Some MPI environments (e.g. SGE) put a link to rsh as "ssh" into the path.
We try to detect that and then use different arguments.

Also moved which() into the ExecEnv class.