Fixed some bugs in both API's