mostly working refactored browserify compat version now