Support browser

I've packed it as an Bower component, it can now be used in browser. Several bugs are also fixed.