Fixed a branch inversion bug and added new structures for the API