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