tools.which: cleanup code a little.