try to fix a possible crash/expection
log error in case of a json response error
some cleanup