API: fixes and error handling

Fixes and error handling improvements after internal Jenkins testing

Change-Id: I819d109887ddc612ed3264d2afe4b9cd4b3e921a
Merge "API: fixes and error handling"