Fixed some coding style issues.
throw error when receiving invalid response.