convert to CommonJS, use browserify, refactoring