Added general annotations and some error handling. Improve some API calls