Added logging and error handling while parsing responses.