Corrected poor code in API.
Merge branch 'master' into api-changes
Merge branch 'master' into api-changes
Fixed really dodgy error handling in API.
Merge remote-tracking branch 'origin/api-changes'