fixes to make it work on the server or with browserify