Fixed improper processing of response and handling of exceptions.