refactor to work with browserify

Fixes #9