Added APIException class
Changed handling of errors and exceptions for api calls
Corrected user logout
Bug