Improve `type` function

Multiple fixes to the `type` function to make it run much faster and behave better.

This includes adding a `-s` flag to the `command` builtin, so we can avoid invoking `which` in the common case for `type`.

Fixes #54.