Refactoring to suit browserify module style