refactored some src code for browserify and coffeescript