Fixes issue where request would crash when there is no referer.
Improves detection of debug mode.
Fixes issue where path could not be resolved when running 'npm start'