Added configuration object to fix #832 and fix #902

Configuration object allows enabling/disabling the localhost
rewrite and also to specify a callback for unhandled
exceptions
Merge pull request #903 from grumpydev/SelfhostUpdates

Added configuration object to fix #832 and fix #902