Various fixes

We tried to use this library in our app and it didn't work, these fixes appeared to make it work.