Improved default base dir detection. Refactor error() for single exit

Two simple changes. 

Refactored `error()` to have a single exit point. (I stopped short of adding an optional `$no_exit` parameter, that was just one possible idea about testability)

Improved the default base directory detection in `dispatch()`. This trick is seen in lots of frameworks and works well. It can still be explicitly overridden by the `config()`.