Refactor before browserify