Fixed some bugs with the API, added rate limiting and an example script.