Bug fixes

Hi, when I tried using this I ran into a bunch of issues. I've fixed them up and it's now working with the official API as released today if you want to pull them in.